SSL certification fails / tweepy

2016-01-13 Thread K. Elo

Dear list members!

I have written I small python script for twitter mining utilising the 
'tweepy' library. Since a couple of days I cannot use the script 
anymore, due to a "ssl certificate verification failed" error. The 
authentication with Twitter API succeess, but when I try to run the 
following code:


--- snip ---

api=tweepy.API(auth)   # 'auth' is my authentification token
print("Receiving network members for '", user_to_track, "' ... ")
network_members = []

#
# The user wants to get all followers of a twitter user
#
while True:
   try:
  for page in tweepy.Cursor(api.followers_ids, user_to_track).pages():
 network_members.extend(page)
 print("Current follower count: ", len(network_members))
 if len(page)==5000: time.sleep(60)
  break
   except tweepy.TweepError as e:
  # Did we exceed the rate limit?
  if e.message[0]["code"]==88:
 # Yes -> sleep for 15 minutes and then continue
 print("Rate limit exceeded, sleeping for 15 minutes ...")
 time.sleep(15*60)
 continue
  else:
 # Something else went wrong -> break out from the loop!
 print("Exception: ", e.message[0], " (", e.code[0], ") --> 
interrupting, sorry!")

 break

--- snip ---

the execution is broken with an "ŚSL_VERIFICATION_FAILED" error.

I have tried both python 2.7 and 3.x, no difference :( I have also 
upgraded 'tweepy', no help.


I suspect this being somehow related to my current system, i.e. openSuSE 
Tumbleweed. I tested the script on a ubuntu system and encountered no 
problems... But I need to get the script running also with my openSuSE :)


Any ideas what could be causing this weird problem?

Thanks in advance!

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


Need solution with this problem

2016-01-13 Thread ifeanyioprah--- via Python-list

Create a class called BankAccount­
Create a constructor that takes in an in­teger and assigns this to a `balance` 
pr­operty.
Create a method called `deposit` that ta­kes in cash deposit amount and updates 
t­he balance accordingly.
Create a method called `withdraw` that t­akes in cash withdrawal amount and 
updat­es the balance accordingly. if amount is­ greater than balance return 
`"invalid t­ransaction"`
Create a subclass MinimumBalanceAccount ­of the BankAccount class
import unittest class AccountBalanceTest­Cases(unittest.TestCase): def 
setUp(self­): self.my_account = BankAccount(90)
def test_balance(self): self.assertEqual­(self.my_account.balance, 90, 
msg='Accou­nt Balance Invalid')
def test_deposit(self): self.my_account.­deposit(90) 
self.assertEqual(self.my_acc­ount.balance, 180, msg='Deposit method 
i­naccurate')
def test_withdraw(self): self.my_account­.withdraw(40) 
self.assertEqual(self.my_a­ccount.balance, 50, msg='Withdraw method­ 
inaccurate')
def test_invalid_operation(self): 
self.a­ssertEqual(self.my_account.withdraw(1000­), "invalid transaction", 
msg='Invalid t­ransaction')
def test_sub_class(self): self.assertTru­e(issubclass(MinimumBalanceAccount, 
Bank­Account), msg='No true subclass of BankA­ccount')
Thank you.­
Pls need assistance. My email : [email protected].
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need solution with this problem

2016-01-13 Thread Tim Golden
On 13/01/2016 05:57, ifeanyioprah--- via Python-list wrote:

[... snip yet another homework dump with one more still held in
moderation ...]

At this point you're basically spamming this list. I won't allow any
more of your posts through unless they appear to be engaging with the
help shown to you (and others?) over the last few days.

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


Re: Which Python editor has this feature?

2016-01-13 Thread Terry Reedy

On 1/12/2016 5:18 AM, Chris Angelico wrote:

On Tue, Jan 12, 2016 at 7:27 PM, Terry Reedy  wrote:



Can psycopg2 be installed with pip?  There is an issue (#23551) to make a
pip GUI and make it accessible from IDLE.  We need someone with both pip and
tkinter knowledge to either design and write it or mentor a GSOC student to
do so.  One written, I would add an IDLE menu item to run it, in a separate
process, just as done now with turtledemo.


Yes, invisible smiley... but with a hint of truth too. Obviously
installing PostgreSQL itself is outside the scope of IDLE, but
psycopg2 is indeed pip-installable... except that it isn't always, on
Windows, because wheels aren't available for all versions. (There's no
Python 3.5 wheel yet; at least, I can't see one on PyPI.)


Maybe someone should give them a prod.  It has been 4 months.
http://www.lfd.uci.edu/~gohlke/pythonlibs/
only has psycopg, for 2.6.

> So what I'm

really looking for isn't an IDLE feature but a Python packaging
feature - some people have talked about setting up build farms that
can produce wheels for people.


Building binaries is a rather different issue, certainly on Windows.


Hmm. I just tried this, and actually, there's some possibly
low-hanging fruit. (Tested on Python 3.4.3 as 3.5 can't install
psycopg2 anyway.)


import pip; pip.main(["install","psycopg2"])


https://bugs.python.org/issue23551
has my report of experimenting with directly using pip.main.  The main 
issue I ran into is that pip creates a cache of 'currently installed 
packages' the first time it needs it and never again during the same 
process.  In other words, pip.main is called exactly once when pip is 
run from the command line.  Another command from the command line starts 
a new process, which makes a new cache.  So calling main() repeatedly 
may fail due to a stale cache.  However, the need to refresh it is 
predictable, so reloading the module may work.



This produces a rather messy display, because pip.main seems to assume
that writing carriage returns to the console will result in the
display nicely overwriting (producing a moving progress bar as the
file gets downloaded). If IDLE can't handle carriage returns as such,
an easy fix would be to simply display them as complete lines; it
would be more verbose than the normal console behaviour, but not as
ugly.


Currently, Idle sends user code output to the tk Text widget as is, 
except for colorizing.  There was an issue about changing this, but it 
was closed, at least for the time being, as Python allows print to send 
output to any file and does not require than stdout be connected to a 
'console', and anyway there is no standard for console behavior.


A gui program that runs pip and displays its output would generally 
parse output for display in differnet widgets.


A couple of other random thoughts from this experiment.

* Going to python.org and pointing the mouse at the download link got
me 3.5.1 32-bit. This is on Google Chrome on a Windows 7 64-bit VM.
* Instead of pip.main(["install","psycopg2"]), I'd like to be able to
say pip.install("psycopg2"). In fact, I might take that to the pip
folks as a suggestion.



* The performance difference between "import pip" on 3.4.3 and 3.5.1
was dramatic! I don't know whether it's CPython that's been sped up or
pip itself, but it's awesome!


Try with 3.4.4, as I believe its installer should also update to the 
most recent pip version.



There's some kind of issue between pip and Idle that means that
installing a non-wheel blows up with an exception:


Traceback (most recent call last):
   File 
"C:\Users\Rosuav\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pip\basecommand.py",
...
 return s.decode(sys.__stdout__.encoding)
AttributeError: 'NoneType' object has no attribute 'encoding'


Assuming that sys.__sydout__ is not None is a bug on pip's part. 
Perhaps you could report it to it list or tracker, and point Donald and 
whoever to https://docs.python.org/3/library/sys.html#sys.__stdin__


"Note

Under some conditions stdin, stdout and stderr as well as the original 
values __stdin__, __stdout__ and __stderr__ can be None. It is usually 
the case for Windows GUI apps that aren’t connected to a console and 
Python apps started with pythonw."


IDLE is a GUI app that on Windows is started with pythonw.exe.  More 
relevant, user code is executed in a windowless pythonw process.  The 
same problem should occur with any IDE that executes user code in a 
pythonw process.


A GUI program could work around the bug by setting sys.__stdin__ to an 
object with a .encoding attribute.  I checked that this can be done.



Maybe calling pip.main just isn't a supported thing, but it'd be nice
if there were _some_ way to do this, even without a fancy GUI.


Calling is once during a process is supported, or supposed to be.
If you ran, at the console,
  > pythonw.exe -c "import pip; pip.main(['install','psycopg2'])"
the same failure would happen.  However, the

Re: Which Python editor has this feature?

2016-01-13 Thread Terry Reedy

On 1/12/2016 8:20 PM, [email protected] wrote:

Terry Reedy at 2016/1/12 UTC+8 3:56:03PM wrote:

Revamping IDLE to 1. use ttk widgets and 2. become a modern single
window app with multiple panes, including a tabbed editor pane, is
a goal for 2016.


That will be great, I'm looking forward to it.

By the way, when I was playing around with the IDLE editor yesterday,
I had noticed that during the time the "Search Dialog" was opened,
"Find Next" button will not highlight the item searched, unless the
dialog was closed.


This was a Windows specific problem that was fixed (for me) in all three 
recent (last November/December) bugfix releases.  If you have a problem 
with *current* IDLE, I would like to know.


--
Terry Jan Reedy

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


Re: Need solution with this problem

2016-01-13 Thread Joel Goldstick
On Wed, Jan 13, 2016 at 3:58 AM, Tim Golden  wrote:

> On 13/01/2016 05:57, ifeanyioprah--- via Python-list wrote:
>
> [... snip yet another homework dump with one more still held in
> moderation ...]
>
> At this point you're basically spamming this list. I won't allow any
> more of your posts through unless they appear to be engaging with the
> help shown to you (and others?) over the last few days.
>
> TJG
> --
> https://mail.python.org/mailman/listinfo/python-list
>


plus 1!
-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which Python editor has this feature?

2016-01-13 Thread Chris Angelico
On Wed, Jan 13, 2016 at 8:05 PM, Terry Reedy  wrote:
> Assuming that sys.__sydout__ is not None is a bug on pip's part. Perhaps you
> could report it to it list or tracker, and point Donald and whoever to
> https://docs.python.org/3/library/sys.html#sys.__stdin__
>
> "Note
>
> Under some conditions stdin, stdout and stderr as well as the original
> values __stdin__, __stdout__ and __stderr__ can be None. It is usually the
> case for Windows GUI apps that aren’t connected to a console and Python apps
> started with pythonw."
>

Thanks! Posted. https://github.com/pypa/pip/issues/3356

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


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-13 Thread bonfaceo3
On Saturday, December 12, 2015 at 12:05:29 PM UTC+3, Harbey Leke wrote:
> Create a class called BankAccount
> 
> .Create a constructor that takes in an integer and assigns this to a 
> `balance` property.
> 
> .Create a method called `deposit` that takes in cash deposit amount and 
> updates the balance accordingly.
> 
> .Create a method called `withdraw` that takes in cash withdrawal amount and 
> updates the balance accordingly. if amount is greater than balance return 
> `"invalid transaction"`
> 
> .Create a subclass MinimumBalanceAccount of the BankAccount class
> 
> Please i need help on this i am a beginer into python programming.
> 
> 
> Also below is a test case given for this project 
> 
> 
> import unittest
> class AccountBalanceTestCases(unittest.TestCase):
>   def setUp(self):
> self.my_account = BankAccount(90)
> 
>   def test_balance(self):
> self.assertEqual(self.my_account.balance, 90, msg='Account Balance 
> Invalid')
> 
>   def test_deposit(self):
> self.my_account.deposit(90)
> self.assertEqual(self.my_account.balance, 180, msg='Deposit method 
> inaccurate')
> 
>   def test_withdraw(self):
> self.my_account.withdraw(40)
> self.assertEqual(self.my_account.balance, 50, msg='Withdraw method 
> inaccurate')
> 
>   def test_invalid_operation(self):
> self.assertEqual(self.my_account.withdraw(1000), "invalid transaction", 
> msg='Invalid transaction')
>   
>   def test_sub_class(self):
> self.assertTrue(issubclass(MinimumBalanceAccount, BankAccount), msg='No 
> true subclass of BankAccount')

lee is right go through the comment thread you will get what you are looking for
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to remove item from heap efficiently?

2016-01-13 Thread Cem Karan

On Jan 12, 2016, at 11:18 AM, "Sven R. Kunze"  wrote:

> On 12.01.2016 03:48, Cem Karan wrote:
>> 
>> Jumping in late, but...
>> 
>> If you want something that 'just works', you can use HeapDict:
>> 
>> http://stutzbachenterprises.com/
>> 
>> I've used it in the past, and it works quite well.  I haven't tested its 
>> asymptotic performance though, so you might want to check into that.
> 
> Thanks for replying here. I've come across these types of 
> wrappers/re-implementations of heapq as well when researching this issue. :)
> 
> Unfortunately, they don't solve the underlying issue at hand which is: 
> "remove item from heap with unknown index" and be efficient at it (by not 
> using _heapq C implementation).
> 
> 
> So, I thought I did another wrapper. ;) It at least uses _heapq (if available 
> otherwise heapq) and lets you remove items without violating the invariant in 
> O(log n). I am going to make that open-source on pypi and see what people 
> think of it.

Is that so?  I'll be honest, I never tested its asymptotic performance, I just 
assumed that he had a dict coupled with a heap somehow, but I never looked into 
the code.

That said, IMHO using a dict interface is the way to go for priority queues; it 
really simplified my code using it!  This is my not-so-subtle way of asking you 
to adopt the MutableMapping interface for your wrapper ;)

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


Re: Data Entry

2016-01-13 Thread Peter Otten
Chris Angelico wrote:

> On Wed, Jan 13, 2016 at 12:52 PM,   wrote:
>> If i change the value from origin to origin energy and save - the value
>> updated to the database is correct but when the page is re displayed it
>> only shows origin in the text field - as if it ignores everything after
>> the space.
>>
>> How do I make it display the full name.
>>
> 
> To set a multi-word value as an HTML attribute, you'll need to put
> quotes around it. You might be able to get away with using %r instead
> of %s, or even just "%s", 

That is bad advice that "works" until there is a value containing 
quotes or other markup.

> but proper escaping would be the best way.

OP, that's what you should do. Either pick one of the many templating 
languages -- a simple one is

http://bottlepy.org/docs/dev/stpl.html

>>> from bottle import SimpleTemplate
>>> SimpleTemplate('... value="{{supplier}}">').render(
... supplier=" 'bar' \"baz\"")
'... value=" 'bar' "baz"">'

-- or at least manually apply html.escape() to the value:

>>> import html
>>> '... value="%s">' % html.escape(" 'bar' \"baz\"")
'... value=" 'bar' "baz"">'


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


Re: Data Entry

2016-01-13 Thread Chris Angelico
On Wed, Jan 13, 2016 at 10:21 PM, Peter Otten <[email protected]> wrote:
>> To set a multi-word value as an HTML attribute, you'll need to put
>> quotes around it. You might be able to get away with using %r instead
>> of %s, or even just "%s",
>
> That is bad advice that "works" until there is a value containing
> quotes or other markup.
>

Which is why I said "get away with". If you know your data, you might
know that it can have spaces but never quotes, for instance. But
proper escaping is definitely the way to go.

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


local variable 'juveniles' referenced before assignment

2016-01-13 Thread Alan Robinson
def menu():
option = int(input("Please select an option: \n 1: Set Generation 0 Values 
\n 2: View Generation 0 Values \n 3: Run Model \n 4: Print values"))

if option == 1:
juveniles,adults,seniles = setGen()
elif option == 2:
displayGen()
elif option == 3:
runModel(juveniles,adults,seniles)
elif option == 4:
print(juveniles,adults,seniles)
menu()


def setGen():
#enter number of juveniles
juveniles = int(input("How many juveniles are in the total popluation?"))
#enter number of adults
adults = int(input("How many Adults are in the total popluation?"))
#enter number of seniles
seniles = int(input("How many Seniles are in the total popluation?"))
#enter juvenilesenile survival rates
return(juveniles,adults,seniles)
menu() 
when I go to print I get the above error I can't see a solution please help
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: local variable 'juveniles' referenced before assignment

2016-01-13 Thread Chris Angelico
On Wed, Jan 13, 2016 at 11:23 PM, Alan Robinson
 wrote:
> def menu():
> option = int(input("Please select an option: \n 1: Set Generation 0 
> Values \n 2: View Generation 0 Values \n 3: Run Model \n 4: Print values"))
>
> if option == 1:
> juveniles,adults,seniles = setGen()
> elif option == 2:
> displayGen()
> elif option == 3:
> runModel(juveniles,adults,seniles)
> elif option == 4:
> print(juveniles,adults,seniles)
> menu()
>

This is a classic use of recursion instead of iteration. When you call
menu() again, you're creating a completely new 'slot' for the new
function; it has its own set of names. Assigning to names in one call
of menu() has no effect on any other call.

Instead, look into the way a while loop works. You'll find that your
code is simpler and clearer, plus your variables will stay set.

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


Re: local variable 'juveniles' referenced before assignment

2016-01-13 Thread Alan Robinson
On Wednesday, 13 January 2016 12:32:51 UTC, Chris Angelico  wrote:
> On Wed, Jan 13, 2016 at 11:23 PM, Alan Robinson
>  wrote:
> > def menu():
> > option = int(input("Please select an option: \n 1: Set Generation 0 
> > Values \n 2: View Generation 0 Values \n 3: Run Model \n 4: Print values"))
> >
> > if option == 1:
> > juveniles,adults,seniles = setGen()
> > elif option == 2:
> > displayGen()
> > elif option == 3:
> > runModel(juveniles,adults,seniles)
> > elif option == 4:
> > print(juveniles,adults,seniles)
> > menu()
> >
> 
> This is a classic use of recursion instead of iteration. When you call
> menu() again, you're creating a completely new 'slot' for the new
> function; it has its own set of names. Assigning to names in one call
> of menu() has no effect on any other call.
> 
> Instead, look into the way a while loop works. You'll find that your
> code is simpler and clearer, plus your variables will stay set.
> 
> ChrisA
thanks I need the menu to run again not sure how to do that though

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


Re: local variable 'juveniles' referenced before assignment

2016-01-13 Thread Chris Angelico
On Wed, Jan 13, 2016 at 11:54 PM, Alan Robinson
 wrote:
> On Wednesday, 13 January 2016 12:32:51 UTC, Chris Angelico  wrote:
>> On Wed, Jan 13, 2016 at 11:23 PM, Alan Robinson
>>  wrote:
>> > def menu():
>> > option = int(input("Please select an option: \n 1: Set Generation 0 
>> > Values \n 2: View Generation 0 Values \n 3: Run Model \n 4: Print values"))
>> >
>> > if option == 1:
>> > juveniles,adults,seniles = setGen()
>> > elif option == 2:
>> > displayGen()
>> > elif option == 3:
>> > runModel(juveniles,adults,seniles)
>> > elif option == 4:
>> > print(juveniles,adults,seniles)
>> > menu()
>> >
>>
>> This is a classic use of recursion instead of iteration. When you call
>> menu() again, you're creating a completely new 'slot' for the new
>> function; it has its own set of names. Assigning to names in one call
>> of menu() has no effect on any other call.
>>
>> Instead, look into the way a while loop works. You'll find that your
>> code is simpler and clearer, plus your variables will stay set.
>>
>> ChrisA
> thanks I need the menu to run again not sure how to do that though

Not quite. You don't want the menu to run again; you want it to
continue to run. Look up the 'while' loop and what it does.

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


Re: local variable 'juveniles' referenced before assignment

2016-01-13 Thread Peter Otten
Alan Robinson wrote:

> On Wednesday, 13 January 2016 12:32:51 UTC, Chris Angelico  wrote:
>> On Wed, Jan 13, 2016 at 11:23 PM, Alan Robinson
>>  wrote:
>> > def menu():
>> > option = int(input("Please select an option: \n 1: Set Generation 0
>> > Values \n 2: View Generation 0 Values \n 3: Run Model \n 4: Print
>> > values"))
>> >
>> > if option == 1:
>> > juveniles,adults,seniles = setGen()
>> > elif option == 2:
>> > displayGen()
>> > elif option == 3:
>> > runModel(juveniles,adults,seniles)
>> > elif option == 4:
>> > print(juveniles,adults,seniles)
>> > menu()
>> >
>> 
>> This is a classic use of recursion instead of iteration. When you call
>> menu() again, you're creating a completely new 'slot' for the new
>> function; it has its own set of names. Assigning to names in one call
>> of menu() has no effect on any other call.
>> 
>> Instead, look into the way a while loop works. You'll find that your
>> code is simpler and clearer, plus your variables will stay set.
>> 
>> ChrisA
> thanks I need the menu to run again not sure how to do that though

def menu():
option = 1 # make sure setGen is invoked on first iteration
while option: # choosing 0 ends the while loop
if option == 1:
   juveniles, adults, seniles = setGen()
elif option == 2:
   ...
option = int(input(...)) # choose option for the next iteration

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


Re: local variable 'juveniles' referenced before assignment

2016-01-13 Thread Alan Robinson
On Wednesday, 13 January 2016 13:06:11 UTC, Peter Otten  wrote:
> Alan Robinson wrote:
> 
> > On Wednesday, 13 January 2016 12:32:51 UTC, Chris Angelico  wrote:
> >> On Wed, Jan 13, 2016 at 11:23 PM, Alan Robinson
> >>  wrote:
> >> > def menu():
> >> > option = int(input("Please select an option: \n 1: Set Generation 0
> >> > Values \n 2: View Generation 0 Values \n 3: Run Model \n 4: Print
> >> > values"))
> >> >
> >> > if option == 1:
> >> > juveniles,adults,seniles = setGen()
> >> > elif option == 2:
> >> > displayGen()
> >> > elif option == 3:
> >> > runModel(juveniles,adults,seniles)
> >> > elif option == 4:
> >> > print(juveniles,adults,seniles)
> >> > menu()
> >> >
> >> 
> >> This is a classic use of recursion instead of iteration. When you call
> >> menu() again, you're creating a completely new 'slot' for the new
> >> function; it has its own set of names. Assigning to names in one call
> >> of menu() has no effect on any other call.
> >> 
> >> Instead, look into the way a while loop works. You'll find that your
> >> code is simpler and clearer, plus your variables will stay set.
> >> 
> >> ChrisA
> > thanks I need the menu to run again not sure how to do that though
> 
> def menu():
> option = 1 # make sure setGen is invoked on first iteration
> while option: # choosing 0 ends the while loop
> if option == 1:
>juveniles, adults, seniles = setGen()
> elif option == 2:
>...
> option = int(input(...)) # choose option for the next iteration

that's really helpful I understand whats happening now I just need to work out 
how to do this loop as I am new it looks difficult to do here goes

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


Re: local variable 'juveniles' referenced before assignment

2016-01-13 Thread Alan Robinson
On Wednesday, 13 January 2016 13:23:04 UTC, Alan Robinson  wrote:
> On Wednesday, 13 January 2016 13:06:11 UTC, Peter Otten  wrote:
> > Alan Robinson wrote:
> > 
> > > On Wednesday, 13 January 2016 12:32:51 UTC, Chris Angelico  wrote:
> > >> On Wed, Jan 13, 2016 at 11:23 PM, Alan Robinson
> > >>  wrote:
> > >> > def menu():
> > >> > option = int(input("Please select an option: \n 1: Set Generation 0
> > >> > Values \n 2: View Generation 0 Values \n 3: Run Model \n 4: Print
> > >> > values"))
> > >> >
> > >> > if option == 1:
> > >> > juveniles,adults,seniles = setGen()
> > >> > elif option == 2:
> > >> > displayGen()
> > >> > elif option == 3:
> > >> > runModel(juveniles,adults,seniles)
> > >> > elif option == 4:
> > >> > print(juveniles,adults,seniles)
> > >> > menu()
> > >> >
> > >> 
> > >> This is a classic use of recursion instead of iteration. When you call
> > >> menu() again, you're creating a completely new 'slot' for the new
> > >> function; it has its own set of names. Assigning to names in one call
> > >> of menu() has no effect on any other call.
> > >> 
> > >> Instead, look into the way a while loop works. You'll find that your
> > >> code is simpler and clearer, plus your variables will stay set.
> > >> 
> > >> ChrisA
> > > thanks I need the menu to run again not sure how to do that though
> > 
> > def menu():
> > option = 1 # make sure setGen is invoked on first iteration
> > while option: # choosing 0 ends the while loop
> > if option == 1:
> >juveniles, adults, seniles = setGen()
> > elif option == 2:
> >...
> > option = int(input(...)) # choose option for the next iteration
> 
> that's really helpful I understand what's happening now I just need to work 
> out how to do this loop as I am new it looks difficult to do here goes not 
> too sure what you mean by make sure setGen is invoked on the first iteration?

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


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-13 Thread phatsammhiel
please assist with the solution on this

p
h
a
t
s
a
m
m
hi
e
[email protected]

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


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-13 Thread phatsammhiel
please kindly inbox me the solution

thanks in anticipation of your kind gesture


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


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-13 Thread Chris Angelico
On Thu, Jan 14, 2016 at 12:28 AM,   wrote:
> please kindly inbox me the solution
>
> thanks in anticipation of your kind gesture
>
>
> [email protected]

Don't you get it? You are not going to be given the code. All you're
doing is making us resent your presence, which means you're less
likely to get help in the future.

Please do not repeatedly post from new email addresses. This is
spamming, and will be reported to Gmail as such.

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


45

2016-01-13 Thread Hongyi Zhao


rt

-- 
.: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread sjmsoft
This strikes me as very good advice.  Thanks for being so far-sighted. And 
let's hope that Python 4 has fewer incompatibilities (none would good) than 
Python 3!

Cheers,
  Steve J. Martin

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


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-13 Thread Joel Goldstick
On Wed, Jan 13, 2016 at 8:37 AM, Chris Angelico  wrote:

> On Thu, Jan 14, 2016 at 12:28 AM,   wrote:
> > please kindly inbox me the solution
> >
> > thanks in anticipation of your kind gesture
> >
> >
> > [email protected]
>
> Don't you get it? You are not going to be given the code. All you're
> doing is making us resent your presence, which means you're less
> likely to get help in the future.
>
> Please do not repeatedly post from new email addresses. This is
> spamming, and will be reported to Gmail as such.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

93 messages in this thread.  a handful are earnest attempts to help a
beginner with what looks like homework.  The rest are an odd barrage of
obsequious please and whining from who knows how many OPs.begging to have
their source code delivered.

bleh

-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-13 Thread Tim Golden
On 13/01/2016 14:43, Joel Goldstick wrote:
> On Wed, Jan 13, 2016 at 8:37 AM, Chris Angelico  wrote:
> 
>> On Thu, Jan 14, 2016 at 12:28 AM,   wrote:
>>> please kindly inbox me the solution
>>>
>>> thanks in anticipation of your kind gesture
>>>
>>>
>>> [email protected]
>>
>> Don't you get it? You are not going to be given the code. All you're
>> doing is making us resent your presence, which means you're less
>> likely to get help in the future.
>>
>> Please do not repeatedly post from new email addresses. This is
>> spamming, and will be reported to Gmail as such.
>>
>> ChrisA
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
> 
> 93 messages in this thread.  a handful are earnest attempts to help a
> beginner with what looks like homework.  The rest are an odd barrage of
> obsequious please and whining from who knows how many OPs.begging to have
> their source code delivered.

I've also held this (and one other) email address for moderation.

TJG

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


Re: How to remove item from heap efficiently?

2016-01-13 Thread srinivas devaki
On Wed, Jan 13, 2016 at 4:50 PM, Cem Karan  wrote:
>
> Is that so?  I'll be honest, I never tested its asymptotic performance, I 
> just assumed that he had a dict coupled with a heap somehow, but I never 
> looked into the code.
>

I have just tested the code, the aymptotic performance is O(log(n))
for all operations. Infact the code is very simple to understand,
technically the heapdict class is composed of a dict and heap, each element of
heap is a mutable list and dict stores references to that mutable list,
so that a specific element can be deleted in O(log(n))
-- 
https://mail.python.org/mailman/listinfo/python-list


Building list

2016-01-13 Thread Eddy Quicksall
What list do I use for building issues? I'm building 3.5.1.

 

Eddy

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


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2016-01-13 Thread Andrew Ongko
On Jan 13, 2016 10:25 PM, "Tim Golden"  wrote:
>
> On 13/01/2016 14:43, Joel Goldstick wrote:
> > On Wed, Jan 13, 2016 at 8:37 AM, Chris Angelico 
wrote:
> >
> >> On Thu, Jan 14, 2016 at 12:28 AM,   wrote:
> >>> please kindly inbox me the solution
> >>>
> >>> thanks in anticipation of your kind gesture
> >>>
> >>>
> >>> [email protected]
> >>
> >> Don't you get it? You are not going to be given the code. All you're
> >> doing is making us resent your presence, which means you're less
> >> likely to get help in the future.
> >>
> >> Please do not repeatedly post from new email addresses. This is
> >> spamming, and will be reported to Gmail as such.
> >>
> >> ChrisA
> >> --
> >> https://mail.python.org/mailman/listinfo/python-list
> >>
> >
> > 93 messages in this thread.  a handful are earnest attempts to help a
> > beginner with what looks like homework.  The rest are an odd barrage of
> > obsequious please and whining from who knows how many OPs.begging to
have
> > their source code delivered.
>
> I've also held this (and one other) email address for moderation.
>
> TJG
>
> --
> https://mail.python.org/mailman/listinfo/python-list

This thread is so annoying, don't you guys think?
At least if it is a homework, one should try to do their best by
themselves. While this one, after getting tons of hints, or even the
answers itself, is still asking for help.
I wonder what is the meaning behind.

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


Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict

2016-01-13 Thread Bernardo Sulzbach
On Tue, Jan 12, 2016 at 11:29 PM, Steven D'Aprano  wrote:
> On Wed, 13 Jan 2016 06:12 am, Bernardo Sulzbach wrote:
>
>> I saw it in another answer. next(iter(d)) is still the winner.
>
> Except that doesn't return the *value*, it returns the *key*.
>

There is a typo, sorry. I assume that what is passed to iter is a
dict_values object.

>> This resembles a list just too much, making the coder's intent harder
>> to understand. This is **very** subjective, of course.
>
> I'm sorry, I don't understand what you mean by "resembles a list"? What
> does? In what way?
>

[a] = d.values()  resembles a list too much to my eyes.

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


Re: Building list

2016-01-13 Thread Steven D'Aprano
On Thu, 14 Jan 2016 02:23 am, Eddy Quicksall wrote:

> What list do I use for building issues? I'm building 3.5.1.

You can ask here.


-- 
Steven

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


Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict

2016-01-13 Thread Grant Edwards
On 2016-01-13, Steven D'Aprano  wrote:
> Probably the best solution, because it will conveniently raise an exception
> if your assumption that the dict has exactly one item is wrong:
>
> item, = d.values()  # Note the comma after "item".

[...]

> but you can unpack a sequence of one item too. If you really want to make it
> obvious that the comma isn't a typo:
>
> (item,) = d.values()

If it were I, I'd definitely do the later.  I used to do it the first
way, but I often times would not notice the comma later when
maintaining the code and end up wasting an embarassing amount of time
when what should have been an easy, trivial change broke.

-- 
Grant Edwards   grant.b.edwardsYow! It was a JOKE!!
  at   Get it??  I was receiving
  gmail.commessages from DAVID
   LETTERMAN!!  !
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Random832
On Wed, Jan 13, 2016, at 09:21, [email protected] wrote:
> This strikes me as very good advice.  Thanks for being so far-sighted.
> And let's hope that Python 4 has fewer incompatibilities (none would
> good) than Python 3!

Who says there's going to be a Python 4? I always assumed 3.9 would be
followed by 3.10.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: When I need classes?

2016-01-13 Thread Rustom Mody
Guess you (Rodrigo) wanted to send this to the list?

On Wed, Jan 13, 2016 at 8:22 PM, Rodrigo Bistolfi  wrote:

> Start by using just functions. As you move forward, you will find that 
> often you are passing the same data structure as first argument to some 
> functions. At that point, you are already using OOP, and you may want to
> formalize that in a class.

>HTH




On Wednesday, January 13, 2016 at 12:01:29 PM UTC+5:30, Rustom Mody wrote:
> On Wednesday, January 13, 2016 at 10:57:23 AM UTC+5:30, Steven D'Aprano wrote:
> > On Wednesday 13 January 2016 14:36, Rustom Mody wrote:
> > 
> > > 1. Python the LANGUAGE, is rather even-handed in paradigm choice: Choose
> > > OO, imperative, functional or whatever style pleases/suits you
> > > 2. Python LIBRARIES however need to make committing choices.  Users of
> > > those then need to align with these.
> > 
> > I don't think that second one is necessarily correct. Look at the random 
> > module: it is based on an OOP design, with classes random.Random and 
> > random.SystemRandom doing the real work. But most people don't use them 
> > directly, they use the procedural interface random.random, random.choice, 
> > random.seed etc.
> > 
> 
> Yes one can have more or less degrees of freedom. Are infinite degrees 
> possible?
> I believe not.
> 
> eg My example of re is strictly not correct: can use strings instead of re 
> objects
> Can use findall instead of search/match and avoid groping around in opaque 
> match
> objects
> So you may conclude that the re module allows these degrees of freedom
> But you cant bold res all the way into the syntax of the language (eg 
> perl/awk)
> 
> Anyway these are side points
> My main point is that when you sit on top of heavy-duty many-layered libraries
> (worse frameworks... OP seems to be trying Kivy) then you have to align with
> the opinionatedness of all the layers down to python.
> 
> Of course that is modulo the leakiness of the abstractions.
> eg mostly python programmers do not need to know the underlying C...
> 
> Mostly...
> And then someone asks about id/is/performance...

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


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Chris Angelico
On Thu, Jan 14, 2016 at 3:25 AM, Random832  wrote:
> On Wed, Jan 13, 2016, at 09:21, [email protected] wrote:
>> This strikes me as very good advice.  Thanks for being so far-sighted.
>> And let's hope that Python 4 has fewer incompatibilities (none would
>> good) than Python 3!
>
> Who says there's going to be a Python 4? I always assumed 3.9 would be
> followed by 3.10.

There most likely will be a Python 4.0 at some point. One theory is
that 3.9 will be followed by 4.0, which will technically have some
backward-incompatible changes (hence it would be inappropriate to call
it 3.10), but in practical terms, good Py3.9 code will be identical to
good Py4.0 code - it'll just remove things that got deprecated during
the 3.x lifecycle.

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


Re: How to remove item from heap efficiently?

2016-01-13 Thread Robin Becker

On 13/01/2016 15:34, srinivas devaki wrote:

On Wed, Jan 13, 2016 at 4:50 PM, Cem Karan  wrote:


Is that so?  I'll be honest, I never tested its asymptotic performance, I just 
assumed that he had a dict coupled with a heap somehow, but I never looked into 
the code.



I have just tested the code, the aymptotic performance is O(log(n))
for all operations. Infact the code is very simple to understand,
technically the heapdict class is composed of a dict and heap, each element of
heap is a mutable list and dict stores references to that mutable list,
so that a specific element can be deleted in O(log(n))

is this true? I looked at https://wiki.python.org/moin/TimeComplexity and it 
says that dict.get which I assume is used for accessing the heapq delete point 
can be large (the average time is O(1), but amortized over a lot of accesses can 
be O(n)). Apparently the history of sets/gets can affect individual times quite 
a lot. I seem to remember there was some kind of hashing attack against python 
dicts that would use up large amounts of time, but I guess that's now fixed.

--
Robin Becker

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


Re: How to remove item from heap efficiently?

2016-01-13 Thread Chris Angelico
On Thu, Jan 14, 2016 at 3:40 AM, Robin Becker  wrote:
> is this true? I looked at https://wiki.python.org/moin/TimeComplexity and it
> says that dict.get which I assume is used for accessing the heapq delete
> point can be large (the average time is O(1), but amortized over a lot of
> accesses can be O(n)). Apparently the history of sets/gets can affect
> individual times quite a lot. I seem to remember there was some kind of
> hashing attack against python dicts that would use up large amounts of time,
> but I guess that's now fixed.

Yes and no. In current CPython versions, the hash attack is made a lot
harder by randomizing the hashes of strings; the most obvious attack
(sending form data to a web site) is now a lot harder, because you
need to figure out what the server process is using as its key. But
there are some caveats to it:

1) CPython 2.7 doesn't (I believe) do this by default. You have to set
PYTHONHASHSEED=random or pass the -R parameter.
2) This still only affects strings. If you build a dictionary out of
integers provided by a potential attacker, the hashes will be
consistent.
3) If an attacker can get info from the server in dictionary order,
the hash key could be deduced. Since it can't change within one run of
a program, this could make attacks possible.

So, I wouldn't say it's *fixed*. It's certainly been made a lot less
easy to abuse than it originally was. That said, though - even before
these fixes, it wasn't something you'd accidentally stumble on. It
takes a deliberate attack.

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


Create notifications in python

2016-01-13 Thread Shiva Upreti
I want to create notification box using python just like I get when battery is 
running low or something similar. I can do it using libnotify in linux, but I 
cant figure out how to do it in windows. I got some codes on internet for this 
like:
https://gist.github.com/wontoncc/1808234, however it didnt work on windows 10. 
It showed the notification icon but nothing else happened. I cant understand 
this code as well.
I would like to ask you how to achieve the above, and what should I learn so 
that I am able to understand what the code above does and learn to write it 
myself. Please provide learning sources if you can, because I cant understand 
any of it so I dont even know from where to begin.

Any help will be highly appreciated.:)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to remove item from heap efficiently?

2016-01-13 Thread Sven R. Kunze

On 13.01.2016 12:20, Cem Karan wrote:

On Jan 12, 2016, at 11:18 AM, "Sven R. Kunze"  wrote:


Thanks for replying here. I've come across these types of 
wrappers/re-implementations of heapq as well when researching this issue. :)

Unfortunately, they don't solve the underlying issue at hand which is: "remove item 
from heap with unknown index" and be efficient at it (by not using _heapq C 
implementation).


So, I thought I did another wrapper. ;) It at least uses _heapq (if available 
otherwise heapq) and lets you remove items without violating the invariant in 
O(log n). I am going to make that open-source on pypi and see what people think 
of it.

Is that so?  I'll be honest, I never tested its asymptotic performance, I just 
assumed that he had a dict coupled with a heap somehow, but I never looked into 
the code.


My concern about that specific package is a missing C-implementation. I 
feel that somewhat defeats the whole purpose of using a heap: performance.


Asymptotic performance is still O(log n).


That said, IMHO using a dict interface is the way to go for priority queues; it 
really simplified my code using it!  This is my not-so-subtle way of asking you 
to adopt the MutableMapping interface for your wrapper ;)


Could you elaborate on this? What simplified you code so much?

I have been using heaps for priority queues as well but haven't missed 
the dict interface so far. Maybe, my use-case is different.


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


me, my arm, my availability ...

2016-01-13 Thread Laura Creighton

I fell recently.  Ought to be nothing, but a small chip of bone, either an
existing one or one I just made is nicely wedged in the joint taking away
a whole lot of the ability of my arm to rotate in the elbow joint.  Or
hold my arm in a position that is usual for typing.  Plus,  now that the
sprain/swelling is more or less over, the pain, unfortunately is not.

The real downside is that my typing speed is down from 135-140 wpm
to 5-10 wmp.  At this rate, just getting my usual work done takes
overtime.

Seems like surgery is needed to fix this. 

So I wanted you all to know, no, I haven't forgotten you and no haven't
stopped caring.  I have just stopped being as __capable__ if you know
what I mean.

Please take care of yourselves and each other.  I will often be reading
even if typing is more than I can do right now.

Laura

ps -- (recent tutor discussion) I am with Alan and not with Mark.  I
am happy as anything when people post their not-quite-working code for
homework assignments here to tutor.  They aren't lazy bastards wanting
somebody to do their assignments for them, they want to learn why what
they are trying to do isn't working.  Sounds perfect for tutor to me.

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


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Gregory Ewing

Steven D'Aprano wrote:

Quote:

if six.PY2:
# Python 2 code
elif six.PY3:
# Python 3 code

In this case, no code will get executed on Python 4 at all!


Which is good, because if no code is executed, it can't exhibit
any bugs.

Everyone should write their code this way, and then Python 4
will make *all* bugs in *all* programs disappear!

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


Re: me, my arm, my availability ...

2016-01-13 Thread David H. Lipman

From: "Laura Creighton" 



I fell recently.  Ought to be nothing, but a small chip of bone, either an


Due to the side-effects of the prescription drugs you were given, I suggest 
you not use a computer until you are no longer taking them.  ;-)



--
Dave
Multi-AV Scanning Tool - http://multi-av.thespykiller.co.uk
http://www.pctipp.ch/downloads/dl/35905.asp 


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


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Bernardo Sulzbach
On Wed, Jan 13, 2016 at 7:38 PM, Gregory Ewing
 wrote:
> Steven D'Aprano wrote:
>>
>> Quote:
>>
>> if six.PY2:
>> # Python 2 code
>> elif six.PY3:
>> # Python 3 code
>>
>> In this case, no code will get executed on Python 4 at all!
>
>
> Which is good, because if no code is executed, it can't exhibit
> any bugs.
>
> Everyone should write their code this way, and then Python 4
> will make *all* bugs in *all* programs disappear!
>

And if that is not enough, imagine how faster all tasks will finish.

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


Re: me, my arm, my availability ...

2016-01-13 Thread Laura Creighton
In a message of Wed, 13 Jan 2016 16:41:57 -0500, "David H. Lipman" writes:
>From: "Laura Creighton" 
>
>>
>> I fell recently.  Ought to be nothing, but a small chip of bone, either an
>
>Due to the side-effects of the prescription drugs you were given, I suggest 
>you not use a computer until you are no longer taking them.  ;-)

God, this is going to make playing games on my android tablet a problem.
And there _was_ a time when under drugs, killing monsters was about all
I was good for ...

Thank you for cheering me up, some.

Nice community this. :)

Laura

>Dave
>Multi-AV Scanning Tool - http://multi-av.thespykiller.co.uk
>http://www.pctipp.ch/downloads/dl/35905.asp 

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


Re: Building list

2016-01-13 Thread Terry Reedy

On 1/13/2016 10:23 AM, Eddy Quicksall wrote:

What list do I use for building issues? I'm building 3.5.1.


Start here.

--
Terry Jan Reedy

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


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Steven D'Aprano
On Thu, 14 Jan 2016 03:25 am, Random832 wrote:

> On Wed, Jan 13, 2016, at 09:21, [email protected] wrote:
>> This strikes me as very good advice.  Thanks for being so far-sighted.
>> And let's hope that Python 4 has fewer incompatibilities (none would
>> good) than Python 3!
> 
> Who says there's going to be a Python 4? I always assumed 3.9 would be
> followed by 3.10.


Guido has a *very* strong dislike for two digit minor version numbers. It
took a fair amount of arm-twisting to get him to accept two digit micro
version numbers, like 2.7.10. It is doubtful that we'll see 3.10.

But he has definitely ruled that 4.0 (assuming there is one) will not be a
major backwards-incompatible version like 3.0 was.

That's not to say that there won't be any backwards incompatibilities at
all, but they will be relatively minor, like the change from 2.5 to 2.6. (I
bet most people don't even know that 2.6 broke backwards-compatibility.)



-- 
Steven

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


Re: [Python-ideas] Password masking for getpass.getpass

2016-01-13 Thread Ian Kelly
On Wed, Jan 13, 2016 at 3:19 AM, Chris Angelico  wrote:
> You're quite probably right that obfuscating the display is security
> theatre; but it's the security theatre that people are expecting. If
> you're about to enter your credit card details into a web form, does
> it really matter whether or not the form itself was downloaded over an
> encrypted link? But people are used to "look for the padlock", which
> means that NOT having the padlock will bother people. If you ask for a
> password and it gets displayed, people will wonder if they're entering
> it in the right place.

I realize that I'm taking this thread off-topic, but yes it's
important that the form itself be downloaded over a secure connection.
If I can MitM the form response over an insecure connection, then I
can also MitM the form itself. And if I can do that, then I can
deliver exactly the form you were expecting, but with an added script
that will read your credit card number as you type it and then fire it
off to be stored on my server before you've even hit the Submit
button.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] Password masking for getpass.getpass

2016-01-13 Thread Chris Angelico
On Thu, Jan 14, 2016 at 11:17 AM, Ian Kelly  wrote:
> On Wed, Jan 13, 2016 at 3:19 AM, Chris Angelico  wrote:
>> You're quite probably right that obfuscating the display is security
>> theatre; but it's the security theatre that people are expecting. If
>> you're about to enter your credit card details into a web form, does
>> it really matter whether or not the form itself was downloaded over an
>> encrypted link? But people are used to "look for the padlock", which
>> means that NOT having the padlock will bother people. If you ask for a
>> password and it gets displayed, people will wonder if they're entering
>> it in the right place.
>
> I realize that I'm taking this thread off-topic, but yes it's
> important that the form itself be downloaded over a secure connection.
> If I can MitM the form response over an insecure connection, then I
> can also MitM the form itself. And if I can do that, then I can
> deliver exactly the form you were expecting, but with an added script
> that will read your credit card number as you type it and then fire it
> off to be stored on my server before you've even hit the Submit
> button.

Noscript FTW.

:)

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


Re: me, my arm, my availability ...

2016-01-13 Thread Steven D'Aprano
On Thu, 14 Jan 2016 07:47 am, Laura Creighton wrote:

> 
> I fell recently.  Ought to be nothing, [...]

Ouch! Much ouch!

Hope you get well soon Laura! My best wishes and sympathies to you!



-- 
Steven

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


Re: me, my arm, my availability ...

2016-01-13 Thread Steven D'Aprano
On Thu, 14 Jan 2016 08:41 am, David H. Lipman wrote:

> From: "Laura Creighton" 
> 
>>
>> I fell recently.  Ought to be nothing, but a small chip of bone, either
>> an
> 
> Due to the side-effects of the prescription drugs you were given, I
> suggest
> you not use a computer until you are no longer taking them.  ;-)


I don't get it. Are you implying that Laura's comments were drug-addled
nonsense? They make perfect sense to me, and seem to be grammatically
correct for informal English (apart from a missing comma), and quite
idiomatic too. And I'm not taking any drugs.

I know that there's a trope of affectionately mocking people on strong
pain-killers ("I want some of the drugs she's having!"), but it's normal to
wait until *after* they've actually demonstrated impairment. Otherwise you
risk having the response which I'm having right now:

"I don't think it's Laura who is high on drugs, prescription 
 or otherwise, but you!"

:-)


Seriously, sorry for being That Guy who asks you to analyse what I expect is
meant as a joke, but I have no idea where the humour is.


-- 
Steven

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


Re: [Python-ideas] Password masking for getpass.getpass

2016-01-13 Thread Steven D'Aprano
On Thu, 14 Jan 2016 11:17 am, Ian Kelly wrote:

> On Wed, Jan 13, 2016 at 3:19 AM, Chris Angelico  wrote:
>> You're quite probably right that obfuscating the display is security
>> theatre; but it's the security theatre that people are expecting. If
>> you're about to enter your credit card details into a web form, does
>> it really matter whether or not the form itself was downloaded over an
>> encrypted link? But people are used to "look for the padlock", which
>> means that NOT having the padlock will bother people. If you ask for a
>> password and it gets displayed, people will wonder if they're entering
>> it in the right place.
> 
> I realize that I'm taking this thread off-topic, but yes it's
> important that the form itself be downloaded over a secure connection.


Not just off-topic, but off-list. You appear to have replied to the wrong
mailing list :-)


> If I can MitM the form response over an insecure connection, then I
> can also MitM the form itself. And if I can do that, then I can
> deliver exactly the form you were expecting, but with an added script
> that will read your credit card number as you type it and then fire it
> off to be stored on my server before you've even hit the Submit
> button.




-- 
Steven

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


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Bernardo Sulzbach
On Wed, Jan 13, 2016 at 10:10 PM, Steven D'Aprano  wrote:
>  (...) 4.0 (assuming there is one)

Isn't it just a matter of time? Do you think it is even possible not
to have Python 4 eventually?

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


Re: [Python-ideas] Password masking for getpass.getpass

2016-01-13 Thread Steven D'Aprano
On Thu, 14 Jan 2016 11:27 am, Chris Angelico wrote:

> On Thu, Jan 14, 2016 at 11:17 AM, Ian Kelly  wrote:

>> I realize that I'm taking this thread off-topic, but yes it's
>> important that the form itself be downloaded over a secure connection.
>> If I can MitM the form response over an insecure connection, then I
>> can also MitM the form itself. And if I can do that, then I can
>> deliver exactly the form you were expecting, but with an added script
>> that will read your credit card number as you type it and then fire it
>> off to be stored on my server before you've even hit the Submit
>> button.
> 
> Noscript FTW.
> 
> :)


What of the poor souls who, for whatever reason, can't use NoScript?

What about those who are so frustrated with trying to get sites to work that
they just Allow All On This Page? I've seen websites that rely on anything
up to forty or fifty externally hosted scripts just to get basic
functionality. (I stopped counting after a while and just kept
clicking "Temporarily Allow...") You have external scripts calling out to
external scripts from completely different domains, each more and more
dodgy-looking than the last. And that's just the "legitimate" (for some
definition of) scripts.




-- 
Steven

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


Re: Which Python editor has this feature?

2016-01-13 Thread jfong
Terry Reedy at 2016/1/13 UTC+8 5:15:20PM wrote:
> This was a Windows specific problem that was fixed (for me) in all three 
> recent (last November/December) bugfix releases.  If you have a problem 
> with *current* IDLE, I would like to know.

I download/install the latest version 3.4.4 and it works perfectly.

It surprise me that how Python society is so active. I had version 3.4.3 
installed 4 months ago and now this problem had already been taken care of:-) 
Thank you.

--Jach Fong

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


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Terry Reedy

On 1/13/2016 7:10 PM, Steven D'Aprano wrote:

On Thu, 14 Jan 2016 03:25 am, Random832 wrote:


On Wed, Jan 13, 2016, at 09:21, [email protected] wrote:

This strikes me as very good advice.  Thanks for being so far-sighted.
And let's hope that Python 4 has fewer incompatibilities (none would
good) than Python 3!


Who says there's going to be a Python 4? I always assumed 3.9 would be
followed by 3.10.



Guido has a *very* strong dislike for two digit minor version numbers. It
took a fair amount of arm-twisting to get him to accept two digit micro
version numbers, like 2.7.10. It is doubtful that we'll see 3.10.

But he has definitely ruled that 4.0 (assuming there is one) will not be a
major backwards-incompatible version like 3.0 was.

That's not to say that there won't be any backwards incompatibilities at
all, but they will be relatively minor, like the change from 2.5 to 2.6. (I
bet most people don't even know that 2.6 broke backwards-compatibility.)


There are a number of deprecations that will not be turned into removals 
while 2.7 remains on support but which probably will be removed after, 
and after they have been giving DeprecationWarnings for at least 2 3.x 
releases.  So code that does not have deprecated features will not be 
affected.


This should be after 3.8.  If removals happen in a release that would be 
'3.9', I expect that it would be '4.0' instead.  (But there is no 
definite plan and will not be until the time comes.


--
Terry Jan Reedy

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


Re: [Python-ideas] Password masking for getpass.getpass

2016-01-13 Thread Michael Torrie
On 01/13/2016 05:47 PM, Steven D'Aprano wrote:
> What of the poor souls who, for whatever reason, can't use NoScript?
> 
> What about those who are so frustrated with trying to get sites to work that
> they just Allow All On This Page? I've seen websites that rely on anything
> up to forty or fifty externally hosted scripts just to get basic
> functionality. (I stopped counting after a while and just kept
> clicking "Temporarily Allow...") You have external scripts calling out to
> external scripts from completely different domains, each more and more
> dodgy-looking than the last. And that's just the "legitimate" (for some
> definition of) scripts.

I seriously doubt there are any web pages that rely on 40 or 50 external
scripts for *basic* functionality.  But I have seen pages that load
dozens of external scripts for tracking, ad, and other purposes.  With
Ghostery I disable almost all of them and guess what, the pages load
faster and work just fine.  I think some companies must think, hey if
one analytics site is good, then 10 are better!  I've seen pages that
refused to load because some analytic script's hosting server was not
responding.  I highly recommend everyone run Ghostery and turn off
nearly all external scripts.  Doesn't usually affect the page's function
itself.  If anything it's educational to see how many external scripts
sites use these days. No wonder we have so many security issues.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread BartC

On 13/01/2016 07:30, Steven D'Aprano wrote:

Quote:

 With the end of support for Python 2 on the horizon (in 2020),
 many package developers have made their packages compatible
 with both Python 2 and Python 3 by using constructs such as:

 if sys.version_info[0] == 2:
 # Python 2 code
 else:
 # Python 3 code



Better still, don't do version checks *at all*. There is almost never any
need for a version check. Better is to use feature detection:


try:
 xrange  # Succeeds in Python 2.
except NameError:
 xrange = range


I was surprised recently by just how much incompatibility there was 
between Python 2 and 3. It wasn't just about print with parentheses and 
range instead of xrange.


I wanted to try out a jpeg decoder with PyPy and the three different 
ones I could find only worked with 2.x. Attempts to fix the 
incompatibilities usually lead to deeper mire.


In the end it was easier to put together my own version, which ran on 
all Pythons (2.7 to 3.4). It was surprisingly easy to do; no need for 
conditional version code.


(It was also smaller and considerably faster than the others even before 
I went tried PyPy. Using range in 2.7 instead of xrange didn't make much 
difference either.)


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


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Rick Johnson
On Wednesday, January 13, 2016 at 6:11:06 PM UTC-6, Steven D'Aprano wrote:
> But [GvR] has definitely ruled that 4.0 (assuming there is
> one) will not be a major backwards-incompatible version
> like 3.0 was.

Well for the sake of Python's future, let's all hope so!

I typically don't give much weight to the statements of
sycophants, but i really do hope your assessment of GvR's
intentions is correct, because it would indicate that "old
hubris" has *FINALLY* come to realize what many of us
feared all along -- that Python3 was going to do more damage
than good!

In fact, in the years before Python3 arrived, it had enjoyed
a steady ascension from obscurity into mainstream hacker
culture, but now, all that remains is a fractured community,
a fractured code base, and a leader who lost his cushy job
at Google -- of which i think Python3 is directly
responsible. Think about it: if they hired him *BECAUSE* of
Python's success then we can *ONLY* conclude they fired him
for mismanaging it.

Folks, our future is in peril, but one thing is guaranteed,
if the introduction of Python4 is *anything* like the
introduction of Python3, well, then, it's curtains for
Python. *CURTAINS*!!!


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


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Steven D'Aprano
On Thu, 14 Jan 2016 11:40 am, Bernardo Sulzbach wrote:

> On Wed, Jan 13, 2016 at 10:10 PM, Steven D'Aprano 
> wrote:
>>  (...) 4.0 (assuming there is one)
> 
> Isn't it just a matter of time? Do you think it is even possible not
> to have Python 4 eventually?

3.9 is probably five or six years away. Perhaps more. A lot can happen in
five years. Just ask Syria.

Maybe Guido will change his mind and we'll have 3.10. 3.11, 3.12, ...

Maybe there will be a sudden and rapid collapse in popularity of Python
between 3.7 and 3.8, and the language is mostly abandoned.

Maybe by the time we approach 3.9, our new xenophobic and fascist overlords
will roll back the internet and ban all that "communist" open source
software, especially those written by foreigners (Dutch or otherwise --
Ruby will be banned too).

Or we're too busy dealing with rising sea levels, crop failures, antibiotic
resistant diseases, chaotic mass migrations, terrorists, wars for control
over resources like water, and the collapse of the corporate state to care
about such little things as upgrades to programming languages.

Or the AI singularity arrives and "human programmer" becomes as obsolete
as "flint knapper".

Or we'll be hit by a big rock from space.

Who knows?




-- 
Steven

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


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Chris Angelico
On Thu, Jan 14, 2016 at 12:02 PM, BartC  wrote:
> I was surprised recently by just how much incompatibility there was between
> Python 2 and 3. It wasn't just about print with parentheses and range
> instead of xrange.
>
> I wanted to try out a jpeg decoder with PyPy and the three different ones I
> could find only worked with 2.x. Attempts to fix the incompatibilities
> usually lead to deeper mire.

This implies that there are many differences between 2.x and 3.x.

> In the end it was easier to put together my own version, which ran on all
> Pythons (2.7 to 3.4). It was surprisingly easy to do; no need for
> conditional version code.

But this implies that the differences are pretty simple. Which
argument are you putting?

The biggest difference between 2.x and 3.x is the handling of text vs
bytes. This is a very important distinction, but for a lot of
programs, it's not difficult; most of what you'll be using will be
text, and the only difference is that the 3.x version of your program
can handle all of Unicode. If you open any files, you might need to
specify encoding="utf-8" or encoding="ascii" or something, but that's
about the only issue.

> (It was also smaller and considerably faster than the others even before I
> went tried PyPy. Using range in 2.7 instead of xrange didn't make much
> difference either.)

Yeah, the effectiveness of xrange over range isn't significant on
smallish lists. And PyPy can optimize all sorts of things. If I'm
writing 2/3 compatible code, I'll usually just use range() everywhere,
unless I know for sure that the lists are going to be huge.

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


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Michael Torrie
On 01/13/2016 06:02 PM, Steven D'Aprano wrote:
> Or we're too busy dealing with rising sea levels, crop failures, antibiotic
> resistant diseases, chaotic mass migrations, terrorists, wars for control
> over resources like water, and the collapse of the corporate state to care
> about such little things as upgrades to programming languages.
> 
> Or the AI singularity arrives and "human programmer" becomes as obsolete
> as "flint knapper".

Most likely, given your apocalyptic scenarios, flintknapping will become
an essential skill again!

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


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Chris Angelico
On Thu, Jan 14, 2016 at 12:02 PM, Rick Johnson
 wrote:
> In fact, in the years before Python3 arrived, it had enjoyed
> a steady ascension from obscurity into mainstream hacker
> culture, but now, all that remains is a fractured community,
> a fractured code base, and a leader who lost his cushy job
> at Google -- of which i think Python3 is directly
> responsible. Think about it: if they hired him *BECAUSE* of
> Python's success then we can *ONLY* conclude they fired him
> for mismanaging it.
>

I got hired by my last boss because he wanted some software written.
I'm no longer employed there. Think about it: if he hired me *BECAUSE*
of software's success, we can ONLY conclude that I mismanaged the very
concept of software. Watch out, folks; software is about to become the
next dead thing!

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


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread BartC

On 14/01/2016 01:21, Chris Angelico wrote:

On Thu, Jan 14, 2016 at 12:02 PM, BartC  wrote:

I was surprised recently by just how much incompatibility there was between
Python 2 and 3. It wasn't just about print with parentheses and range
instead of xrange.

I wanted to try out a jpeg decoder with PyPy and the three different ones I
could find only worked with 2.x. Attempts to fix the incompatibilities
usually lead to deeper mire.


This implies that there are many differences between 2.x and 3.x.


In the end it was easier to put together my own version, which ran on all
Pythons (2.7 to 3.4). It was surprisingly easy to do; no need for
conditional version code.


But this implies that the differences are pretty simple. Which
argument are you putting?


That they are plenty of differences but I was adept at avoiding them!

They didn't come up in my 700-line module anyway, except for the use of 
'bytearray' which required upgrading from 2.5 to 2.7. (I needws to make 
use of bytearrays otherwise it could run out of memory on large inputs.)


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


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Michael Torrie
On 01/13/2016 06:02 PM, Rick Johnson wrote:
> In fact, in the years before Python3 arrived, it had enjoyed
> a steady ascension from obscurity into mainstream hacker
> culture, but now, all that remains is a fractured community,
> a fractured code base, and a leader who lost his cushy job
> at Google -- of which i think Python3 is directly
> responsible. Think about it: if they hired him *BECAUSE* of
> Python's success then we can *ONLY* conclude they fired him
> for mismanaging it.

Hmm, so Guido moved to Dropbox because Google fired him?  Interesting
revisionist history there.  I can find zero evidence to support your
assertion, so we can *ONLY* conclude that you are making stuff up.
Dishonesty is a harsh accusation, but when one makes up stuff to support
one's argument, is that not lying?

Besides that, people leave good jobs all the time for other more
challenging jobs.  Who says it was cushy?  Cushy because Google paid him
to work on Python?  Sounds like the move to Dropbox suited him just fine
and he and Python are both doing well. I'm sure there were contributing
factors to his decision to leave Google, like Google's NIH syndrome
(golang, dart, etc).  Things happen.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: me, my arm, my availability ...

2016-01-13 Thread Joel Goldstick
On Wed, Jan 13, 2016 at 7:30 PM, Steven D'Aprano 
wrote:

> On Thu, 14 Jan 2016 08:41 am, David H. Lipman wrote:
>
> > From: "Laura Creighton" 
> >
> >>
> >> I fell recently.  Ought to be nothing, but a small chip of bone, either
> >> an
> >
> > Due to the side-effects of the prescription drugs you were given, I
> > suggest
> > you not use a computer until you are no longer taking them.  ;-)
>
>
> I don't get it. Are you implying that Laura's comments were drug-addled
> nonsense? They make perfect sense to me, and seem to be grammatically
> correct for informal English (apart from a missing comma), and quite
> idiomatic too. And I'm not taking any drugs.
>
> I know that there's a trope of affectionately mocking people on strong
> pain-killers ("I want some of the drugs she's having!"), but it's normal to
> wait until *after* they've actually demonstrated impairment. Otherwise you
> risk having the response which I'm having right now:
>
> "I don't think it's Laura who is high on drugs, prescription
>  or otherwise, but you!"
>
> :-)
>
>
> Seriously, sorry for being That Guy who asks you to analyse what I expect
> is
> meant as a joke, but I have no idea where the humour is.
>
>
> --
> Steven
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

I enjoy Laura.  Excellent advice, informed.. wishing her injury heels soon.
  A great asset to the python interested community

-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Rick Johnson
On Wednesday, January 13, 2016 at 8:11:40 PM UTC-6, Michael Torrie wrote:
> Hmm, so Guido moved to Dropbox because Google fired him?
> [...] I can find zero evidence to support your assertion,

Feel free to post evidence that will *DISPROVE* my statement.

> Dishonesty is a harsh accusation, but when one makes up
> stuff to support one's argument, is that not lying?

You cannot accuse me of lying until you provide *PROOF* that
i am lying. But even if you offered proof, that GvR was not
fired because of Python's downward spiral, your implication
that an "assertion" is "a lie" is in itself dishonest
(yes?). And your interpretation of my statement "as
malicious" does speak volumes to your true feelings on the
subject. Why do you feel *SO* compelled to speak on behalf
of GvR? And furthermore, what gives you the right to speak on
his behalf?

> Besides that, people leave good jobs all the time for
> other more challenging jobs. Who says it was cushy?  Cushy
> because Google paid him to work on Python?

Getting paid to work on Pyhton 20% of the time is a pretty
damn cushy job Micheal! How much time does *YOUR* employer
pay *YOU* to work on "side projects"?

> Sounds like the move to Dropbox suited him just fine

Sounds like conjecture to me. What evidence do you have that
will support your position? I provided the evidence that
lead me to my conclusion, sure, you may not agree, but at
least i provided more than just denial.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Gene Heskett
On Wednesday 13 January 2016 21:39:12 Dennis Lee Bieber wrote:

> On Thu, 14 Jan 2016 12:02:59 +1100, Steven D'Aprano
> 
>
> declaimed the following:
> >On Thu, 14 Jan 2016 11:40 am, Bernardo Sulzbach wrote:
> >> On Wed, Jan 13, 2016 at 10:10 PM, Steven D'Aprano
> >> 
> >>
> >> wrote:
> >>>  (...) 4.0 (assuming there is one)
> >>
> >> Isn't it just a matter of time? Do you think it is even possible
> >> not to have Python 4 eventually?
> >
> >3.9 is probably five or six years away. Perhaps more. A lot can
> > happen in five years. Just ask Syria.
> >
> >Maybe Guido will change his mind and we'll have 3.10. 3.11, 3.12, ...
>
>   3.14.15926...

Apple, Blueberry or Peach? Preferably ala-mode.

Must... Learn.. To Resist. I am a DM-II victim. :(
> --
>   Wulfraed Dennis Lee Bieber AF6VN
> [email protected]://wlfraed.home.netcom.com/


Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Chris Angelico
On Thu, Jan 14, 2016 at 1:51 PM, Rick Johnson
 wrote:
> On Wednesday, January 13, 2016 at 8:11:40 PM UTC-6, Michael Torrie wrote:
>> Hmm, so Guido moved to Dropbox because Google fired him?
>> [...] I can find zero evidence to support your assertion,
>
> Feel free to post evidence that will *DISPROVE* my statement.
>
>> Dishonesty is a harsh accusation, but when one makes up
>> stuff to support one's argument, is that not lying?
>
> You cannot accuse me of lying until you provide *PROOF* that
> i am lying.

That's not how it goes. You provided assertions; you should provide at
least some sort of supporting evidence.

> But even if you offered proof, that GvR was not
> fired because of Python's downward spiral, your implication
> that an "assertion" is "a lie" is in itself dishonest
> (yes?). And your interpretation of my statement "as
> malicious" does speak volumes to your true feelings on the
> subject. Why do you feel *SO* compelled to speak on behalf
> of GvR? And furthermore, what gives you the right to speak on
> his behalf?

You're talking about a very serious matter between two legal entities
- if someone was *fired* because of social, technological, or other
problems with Python, that has implications that could matter in a
court of law. So I put it right back to you: What gives you the right
to speak against Guido and Google?

>> Besides that, people leave good jobs all the time for
>> other more challenging jobs. Who says it was cushy?  Cushy
>> because Google paid him to work on Python?
>
> Getting paid to work on Pyhton 20% of the time is a pretty
> damn cushy job Micheal! How much time does *YOUR* employer
> pay *YOU* to work on "side projects"?

It's hardly a side project if it's creating something of immense value
to the company. And Google is still getting immense value from Python
even now that they're not paying Guido's salary.

And Michael's right: people move around for all sorts of reasons.
Doesn't necessarily mean anything about the previous job.

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


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Rick Johnson
On Wednesday, January 13, 2016 at 9:08:40 PM UTC-6, Chris Angelico wrote:
> You're talking about a very serious matter between two legal entities
> - if someone was *fired* because of social, technological, or other
> problems with Python, that has implications that could matter in a
> court of law. So I put it right back to you: What gives you the right
> to speak against Guido and Google?

I'm not speaking *AGAINST* anyone, i'm merely trying to
understand what happened. And unless there was some sort of
explicit contract, Google could fire *ANYONE* for *ANY*
reason -- this is not France, Chris!

> And Michael's right: people move around for all sorts of reasons.
> Doesn't necessarily mean anything about the previous job.

Of course. But when you leave things open for speculation,
you enviably create a situation where rumors can start
circulating. GvR is not just any "John Doe" engineer, no,
he's the head of an open source community, and the community
has a right to be concerned about the livelihood and well
being of their leader.

Not because we need something to gossip about whilst
watching reruns of Monty Python, but because we need to know
if Python is going to be viable into the foreseeable future.
More specifically, we need to know if we're writing code in
a language that is heading back to the obscurity from wench
it came. We have a *RIGHT* to be worried Chris, because our
livelihoods are directly dependent on Python.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Michael Torrie
On 01/13/2016 08:29 PM, Rick Johnson wrote:
> Of course. But when you leave things open for speculation,
> you enviably create a situation where rumors can start
> circulating. GvR is not just any "John Doe" engineer, no,
> he's the head of an open source community, and the community
> has a right to be concerned about the livelihood and well
> being of their leader.

The only one speculating is you.  Everything I've read points to this
idea of yours about GvR and Google being untrue.  You have presented no
evidence for your accusation, so given the evidence I have seen that
contradicts you, I must conclude that you made it. That's the part I
take issue with and why I stopped to feed the troll, much to the chagrin
of everyone else.

> We have a *RIGHT* to be worried Chris, because our livelihoods are
> directly dependent on Python.

I don't know who the "we" you're talking about is, but if your
livelihood depends on Python's existence and development in a certain
direction, then I suggest you hire GvR--that's what Dropbox did and they
don't seem too worried about Python's future.  Python's doing just fine,
but you should be able to adapt to any programming language suitable for
your job at hand.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Terry Reedy

On 1/13/2016 8:02 PM, Rick Johnson wrote:

and a leader who lost his cushy job at Google


Unless you have access to facts that I do not, 'lost' is impolite 
speculation. But lets move on.


I have a contrary hypothesis based on the facts quoted below.  As far as 
I know, Google is somewhat stuck on 2.7.  Dropbox, on the other, is 
migrating to modern 3.x Python (see below).  Guido wants the world to do 
this, so he moved to a company where he can help make this practical, by 
helping to work out some of the practical details of how to do so, and 
then share them with the rest of the Python community.


On Jan 8, 6 days ago, Guido posted on python-idea "Proposal to extend 
PEP 484 (gradual typing) to support Python 2.7"


"At Dropbox we're trying to be good citizens and we're working towards 
introducing gradual typing (PEP 484) into our Python code bases (several 
million lines of code). However, that code base is mostly still Python 
2.7 and we believe that we should introduce gradual typing first and 
start working on conversion to Python 3 second (since having static 
types in the code can help a big refactoring like that).


Since Python 2 doesn't support function annotations we've had to look 
for alternatives. We considered stub files, a magic codec, docstrings, 
and additional `# type:` comments. In the end we decided that `# type:` 
comments are the most robust approach. We've experimented a fair amount 
with this and we have a proposal for a standard."


A few days later, in the absence of objection to the proposed comment 
syntax, he added the proposal.  Not mentioned in the quote is that mypy 
will support the new comments for static analysis.  2.x interpreters 
will happily ignore then.


If Dropbox comment-annotates a public 2.x package, it can contribute the 
work back for the use of others.  Google, on the other hand, decided to 
support annotation in 2.7 creating a custom 2.7 interpreter than will 
ignore them.  Any code annotated by Google will be useless on standard 
interpreters without being run through a converter.


--
Terry Jan Reedy

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


Stop writing Python 3.5 incompatible code :-)

2016-01-13 Thread Frank Millman
This is a tongue-in-cheek follow-up to the thread on Python 4 incompatible 
code, but it did happen to me, and may help someone else.


I execute a lot of database SELECT commands. In many cases I expect to get 
only one row returned, but it could be zero or more than one.


Using LBYL, one would retrieve the row(s) and check the length. I found a 
way to use EAFP, as follows -


cur.execute('SELECT ...')
(row,) = cur

This uses tuple unpacking, and only works if exactly one row is returned. If 
it fails it raises ValueError, but I need to know whether it failed because 
no rows were returned, or more than one row was returned. The only way I 
could figure out how to achieve this was to parse the error message.


If 0 rows were returned, the message is 'need more than 0 values to unpack'.

If > 1 rows were returned, the message is 'too many values to unpack'.

So my test was -

except ValueError as e:
   if str(e).startswith('need'):
   # 0 rows returned
   else:
   # > 1 rows returned

This has worked for years, but with 3.5 it stopped working. It took me a 
while to figure out why. Lo and behold, the error message has changed! Now, 
if 0 rows are returned, the message is 'not enough values to unpack'.


Luckily the other message has not changed, so now my test is -

except ValueError as e:
   if str(e).startswith('too many'):
   # > 1 rows returned
   else:
   # 0 rows returned

Now it works with both versions.

Frank Millman


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


Re: When I need classes?

2016-01-13 Thread Mike S via Python-list

On 1/11/2016 3:45 PM, Travis Griggs wrote:



On Jan 10, 2016, at 9:48 AM, Bernardo Sulzbach  
wrote:

Essentially, classes (as modules) are used mainly for organizational purposes.

Although you can solve any problem you would solve using classes
without classes, solutions to some big problems may be cheaper and
more feasible using classes.


As a long term OO purist practitioner, I would add to this. Obviously, you can 
organize your code any way you want, with or without classes. You could put all 
your functions with an odd number of letters in one class, and all of the even 
numbered ones in another class.

Having listened to the guy (Alan Kay) who coined the term (Object Oriented 
Programming) quite a bit over the years, I believe that the focus of OO (of 
which classes are a particular implementation approach) is to bind behavior to 
data. In “traditional” programming approaches, one focused on the algorithm 
(behavior) first, and then figured out what data needed to flow where to get 
the job done. Classes provided a mechanism to turn that equation, generally 
speaking, around. One thinks about the data first, and then figures out what 
behavior binds best to that data. And how that data will interact (inter-object 
behavior, often called messages) to get your job done. For some (many) 
problems, this can be a real win. And for some, not so much.

I think, this is often why, for a simple script, OO just kind of gets in the 
way. You have a straightforward procedure that you just want to do. The state 
(data) is not rich enough to make making it the focal point of your program.


Well said, thanks!


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


Re: [Python-ideas] Password masking for getpass.getpass

2016-01-13 Thread Marko Rauhamaa
Steven D'Aprano :

> What about those who are so frustrated with trying to get sites to
> work that they just Allow All On This Page?

I'm occasionally frustrated by that, but I simply won't read that page.
Nothing truly important is lost.


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


Re: Stop writing Python 3.5 incompatible code :-)

2016-01-13 Thread Chris Angelico
On Thu, Jan 14, 2016 at 5:27 PM, Frank Millman  wrote:
> Using LBYL, one would retrieve the row(s) and check the length. I found a
> way to use EAFP, as follows -
>
> cur.execute('SELECT ...')
> (row,) = cur
>
> This uses tuple unpacking, and only works if exactly one row is returned. If
> it fails it raises ValueError, but I need to know whether it failed because
> no rows were returned, or more than one row was returned. The only way I
> could figure out how to achieve this was to parse the error message.

That seems like a tricky way to do things. How about this:

cur.execute(...)
rows = iter(cur)
try:
row = next(rows)
except StopIteration:
# 0 rows returned
try:
next(rows)
except StopIteration: pass
else:
# >1 rows returned

It's a bit more verbose, but it's reliable. Alternatively, since you
know that a returned row will never be None:

cur.execute(...)
rows = iter(cur)
row, extra = next(rows), next(rows)
if row is None:
# 0 rows returned
if extra is not None:
# >1 rows returned

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


Re: Stop writing Python 3.5 incompatible code :-)

2016-01-13 Thread Frank Millman
"Chris Angelico"  wrote in message 
news:captjjmps+vfu33tulae5oivrvn_otfuxrp8yluy68qmu36-...@mail.gmail.com...



On Thu, Jan 14, 2016 at 5:27 PM, Frank Millman  wrote:
> Using LBYL, one would retrieve the row(s) and check the length. I found 
> a

> way to use EAFP, as follows -
>
> cur.execute('SELECT ...')
> (row,) = cur
>
> This uses tuple unpacking, and only works if exactly one row is 
> returned. If
> it fails it raises ValueError, but I need to know whether it failed 
> because

> no rows were returned, or more than one row was returned. The only way I
> could figure out how to achieve this was to parse the error message.

That seems like a tricky way to do things. How about this:

cur.execute(...)
rows = iter(cur)
try:
row = next(rows)
except StopIteration:
# 0 rows returned
try:
next(rows)
except StopIteration: pass
else:
# >1 rows returned

It's a bit more verbose, but it's reliable. Alternatively, since you
know that a returned row will never be None:

cur.execute(...)
rows = iter(cur)
row, extra = next(rows), next(rows)
if row is None:
# 0 rows returned
if extra is not None:
# >1 rows returned



Thanks, Chris. I did feel unhappy relying on the contents of an error 
message, so I will follow up on your suggestion.


I like your first solution. In fact, with sqlite3, 'cur' is already 
iterable, so I can just say


cur.execute(...)
try:
   row = next(cur)
except StopIteration:
   # 0 rows returned
try:
   next(cur)
except StopIteration: pass
else:
   # >1 rows returned

I will have to check if this works with psycopg2 and pyodbc, the other two 
adaptors that I use.


Your second solution does not seem to work - if it raises StopIteration, 
neither 'row' nor 'extra' is populated. I may be doing it wrong, but no 
matter, I prefer the first one anyway.


There is one slight downside that I can see. I believe that raising an 
exception is a relatively expensive operation in Python. For this reason, a 
rule of thumb is to use EAFP when the usual case is to have no exception, 
and LBYL otherwise. With my approach, I do not get an exception if exactly 
one row is returned. With yours, you rely on raising an exception to 
determine the result.


I can think of two counter-arguments to that. Firstly, it is more important 
to ensure that the program is correct than to shave off a few microseconds. 
Secondly, as StopIteration is used extensively under the hood in modern 
pythons, it is probably highly optimised, and therefore nothing to be 
worried about.


Frank


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