Re: A problem with classes - derived type

2016-05-08 Thread Yann Kaiser
If you can't change A to use something like "type(self)(...)" to create its
return value, you could use the dark side and swap res's __class__:

res.__class__ = B

Or:

res.__class__ = type(self)

Do note that B.__init__ will not be run when you do this, so it is up to
you to execute any additional initialization B might require.

Alternatively if it makes sense for you you can call B's methods on an A
object like so:

B.b_method(a_object, ...)

On Mon, 9 May 2016 at 06:26 Paulo da Silva 
wrote:

> Hi!
>
> Suppose I have a class A whose implementation I don't know about.
> That class A has a method f that returns a A object.
>
> class A:
> ...
> def f(self, <...>):
> ...
>
> Now I want to write B derived from A with method f1. I want f1 to return
> a B object:
>
> class B(A):
> ...
> def f1(self, <...>):
> ...
> res=f(<...>)
>
> How do I return res as a B object?
>
> Thanks.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Yann Kaiser
kaiser.y...@gmail.com
yann.kai...@efrei.net
+33 6 51 64 01 89
https://github.com/epsy
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a reason zip() wipes out data?

2016-05-08 Thread Paul Rubin
DFS  writes:
> Edit: I see they addressed this in 3.5 (maybe earlier), with an option:
> "itertools.zip_longest(*iterables, fillvalue=None)

This is available in 2.7 as itertools.izip_longest
-- 
https://mail.python.org/mailman/listinfo/python-list


pygame easy create

2016-05-08 Thread harirammanohar
is there anyway (IDE/package) that allows me to create graphics/game just like 
that (by instructing..., if i say create hills on the screen, it should 
generate pygame code)Anyway :) :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python PygLatin

2016-05-08 Thread Cai Gengyang
I am guessing that the 2 you mentioned are Bill Gates and Larry Ellison ? I 
heard that they have tons of lawsuits against them in their career 
(anti-monopoly, anti-competitive laws filed against them both from the 
government and from individuals) ?

Paul Graham has this very interesting related essay on meanness and success 
--http://paulgraham.com/mean.html






On Monday, May 9, 2016 at 1:53:31 AM UTC+8, alister wrote:
> On Mon, 09 May 2016 03:12:14 +1000, Steven D'Aprano wrote:
> 
> > On Sun, 8 May 2016 08:21 pm, Cai Gengyang wrote:
> > 
> >> If one looks at the Forbes List, you will see that there are 4
> >> programmers amongst the top ten richest people in the world (Bill
> >> Gates, Mark Zuckerberg, Larry Ellison and Jeff Bezos) , a very large
> >> percentage. Science and Technology is in a sense the most egalitarian
> >> field in the world, because it involves using your brains and
> >> creativity. You don't need to have a father who is a director at
> >> Goldman Sachs or a mother who is the admissions officer at Harvard to
> >> succeed in this line.
> > 
> > Bill Gates III's father was a prominent lawyer, his mother was on the
> > board of directors for First Interstate BancSystem and United Way, and
> > one of his grandfathers was a national bank president. Gates himself
> > went to Harvard.
> > 
> > Zuckerberg's paternal grandparents were successful middle class,
> > described as  being the first on the block to own a colour TV. (This was
> > back in the days when colour TVs were an expensive toy that few could
> > afford.) His parents were also very successful professionals: a dentist
> > and a psychiatrist. And he too went to Harvard. Despite the jeans and
> > tee-shirts Zuckerberg is known for wearing, he's firmly from the
> > professional/upper class.
> > 
> > Bezos comes from a family of land-holders from Texas. His grandfather
> > was regional director of the U.S. Atomic Energy Commission, and was
> > financially successful enough to retire at an early age. He didn't go to
> > Harvard, but he did go to Princeton.
> > 
> > Ellison is the son of an unwed mother who gave him up for adoption by
> > her aunt and uncle, comfortably middle-class. That makes him the closest
> > out of the group as a "regular guy".
> 
> And at least 2 of the above reached their position using business 
> practices that could be described as less than 100% honorable & above 
> board.
> 
> 
> 
> 
> -- 
> Wait ... is this a FUN THING or the END of LIFE in Petticoat Junction??
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a reason zip() wipes out data?

2016-05-08 Thread Dan Sommers
On Mon, 09 May 2016 00:22:46 -0400, DFS wrote:

> python 2.7.11 docs: "The returned list is truncated in length to the 
> length of the shortest argument sequence."
> 
> 
> a = ['who','let','the']
> b = ['dogs','out?']
> c = zip(a,b)
> 
> print c
> [('who', 'dogs'), ('let', 'out?')]
> 
> 
> Wouldn't it be better to return an empty element than silently kill your 
> data?
> 
> [('who', 'dogs'), ('let', 'out?'), ('the', '')]

>>> dfs_zip([1, 2, 3], [4, 5])
[(1, 4), (2, 5), (3, '')]

No, that's not much better, thanks.

In the face of ambiguity, refuse the temptation to guess.
-- 
https://mail.python.org/mailman/listinfo/python-list


Is there a reason zip() wipes out data?

2016-05-08 Thread DFS
python 2.7.11 docs: "The returned list is truncated in length to the 
length of the shortest argument sequence."



a = ['who','let','the']
b = ['dogs','out?']
c = zip(a,b)

print c
[('who', 'dogs'), ('let', 'out?')]


Wouldn't it be better to return an empty element than silently kill your 
data?


[('who', 'dogs'), ('let', 'out?'), ('the', '')]




Edit: I see they addressed this in 3.5 (maybe earlier), with an option:

"itertools.zip_longest(*iterables, fillvalue=None)

Make an iterator that aggregates elements from each of the iterables. If 
the iterables are of uneven length, missing values are filled-in with 
fillvalue. Iteration continues until the longest iterable is exhausted."


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


A problem with classes - derived type

2016-05-08 Thread Paulo da Silva
Hi!

Suppose I have a class A whose implementation I don't know about.
That class A has a method f that returns a A object.

class A:
...
def f(self, <...>):
...

Now I want to write B derived from A with method f1. I want f1 to return
a B object:

class B(A):
...
def f1(self, <...>):
...
res=f(<...>)

How do I return res as a B object?

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


Re: String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?)

2016-05-08 Thread srinivas devaki
f be gfdnbh be b GB GB BH GB vbjfhjb GB bffbbubbv GB hbu hbu
fjbjfbbbufhbvh VB have fqbgvfb NB bb GB GB GB GB bbu GB vu GB vu GB GB
b GB fbufjnb BH GB GB bvvfbubbjubuv GB b fbufbbby GB bfff GB f GB
bbbu GB GB ffinj GB vh vh fjb GB fj GB h h GB gjfthey're the b GB gjf GBG
GBG q GB fbb b bh VB ffbff GBG fbfvrgv
On May 9, 2016 7:49 AM, "Chris Angelico"  wrote:

On Mon, May 9, 2016 at 10:44 AM, Thomas 'PointedEars' Lahn
 wrote:
> With the “%” string operator (deprecated), str.format(), and str.Template,
> you can use other values in string values even without concatenation.

Not deprecated. Don't spread FUD.

> Finally, with SQL you should prefer Prepared Statements and Stored
> Procedures, not bare strings, to avoid SQL injection:
>
> 

He is safe. He's using parameterized queries.

> Also, it would be a good idea if you posted under your real name.
Internet
> is the thing with cables; Usenet is the thing with people.  I for one tend
> to avoid communicating with few-letter entities; exceptions to that would
> probably include only E.T., M.J., ALF, and K.I.T.T.

I'm not using Usenet, Mr PointedEars.

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


Re: String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?)

2016-05-08 Thread srinivas devaki
I'm so sorry, forgot to lock my phone.
On May 9, 2016 9:01 AM, "srinivas devaki" 
wrote:

> f be gfdnbh be b GB GB BH GB vbjfhjb GB bffbbubbv GB hbu hbu
> fjbjfbbbufhbvh VB have fqbgvfb NB bb GB GB GB GB bbu GB vu GB vu GB GB
> b GB fbufjnb BH GB GB bvvfbubbjubuv GB b fbufbbby GB bfff GB f GB
> bbbu GB GB ffinj GB vh vh fjb GB fj GB h h GB gjfthey're the b GB gjf GBG
> GBG q GB fbb b bh VB ffbff GBG fbfvrgv
> On May 9, 2016 7:49 AM, "Chris Angelico"  wrote:
>
> On Mon, May 9, 2016 at 10:44 AM, Thomas 'PointedEars' Lahn
>  wrote:
> > With the “%” string operator (deprecated), str.format(), and
> str.Template,
> > you can use other values in string values even without concatenation.
>
> Not deprecated. Don't spread FUD.
>
> > Finally, with SQL you should prefer Prepared Statements and Stored
> > Procedures, not bare strings, to avoid SQL injection:
> >
> > 
>
> He is safe. He's using parameterized queries.
>
> > Also, it would be a good idea if you posted under your real name.
> Internet
> > is the thing with cables; Usenet is the thing with people.  I for one
> tend
> > to avoid communicating with few-letter entities; exceptions to that would
> > probably include only E.T., M.J., ALF, and K.I.T.T.
>
> I'm not using Usenet, Mr PointedEars.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pylint woes

2016-05-08 Thread Steven D'Aprano
On Mon, 9 May 2016 07:24 am, DFS wrote:

> On 5/8/2016 7:36 AM, Steven D'Aprano wrote:
>> On Sun, 8 May 2016 11:16 am, DFS wrote:
>>
>>> address data is scraped from a website:
>>>
>>> names = tree.xpath()
>>> addr  = tree.xpath()
>>
>> Why are you scraping the data twice?
> 
> 
> Because it exists in 2 different sections of the document.
> 
> names = tree.xpath('//span[@class="header_text3"]/text()')
> addresses = tree.xpath('//span[@class="text3"]/text()')

How was I supposed to know that you were providing two different arguments
to the method? It looked like a pure-function call, which should always
return the same thing. Communication errors are on the sender, not the
receiver.

You didn't say what tree was, so I judged that xpath was some argument-less
method of tree that returned some attribute, sufficiently cleaned up.

It would be more obvious to pass a placeholder argument:

names = tree.xpath(this)
addr  = tree.xpath(that)



>>> I want to store the data atomically,
>>
>> I'm not really sure what you mean by "atomically" here. I know what *I*
>> mean by "atomically", which is to describe an operation which either
>> succeeds entirely or fails.
> 
> That's atomicity.

Right. And that doesn't apply to the portion of your code we're discussing.
There's no storage involved. The list comps do either succeed entirely or
fail, until you actually get to writing to the database, there's nothing
that "store the data atomically" would apply to that I saw.


[...]
>>> so I parse street, city, state, and
>>> zip into their own lists.
>>
>> None of which is atomic.
> 
> All of which are atomic.

Sorry, my poor choice of words. None of which are atomic *storage*.



>> Oh, and use better names. "street" is a single street, not a list of
>> streets, note plural.
> 
> I'll use whatever names I like.

*shrug*

Its your code, you can name all your variables after "Mr. Meeseeks" if you
want.

for meeseeks, Meeseeks, meeSeeks, MEEseeks in zip(
MESEEKS, meeeseeks, MeesEeks, MEEsEEkS):
mEEsEeKSS.append(meeSeeks)
...


Just don't ask others to read it.



-- 
Steven

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


Re: pylint woes

2016-05-08 Thread Steven D'Aprano
On Mon, 9 May 2016 07:04 am, DFS wrote:

> On 5/8/2016 11:51 AM, Steven D'Aprano wrote:
>> On Mon, 9 May 2016 12:25 am, DFS wrote:
>>
> for j in range(len(nms)):
>  cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)"
>  vals = nms[j],street[j],city[j],state[j],zipcd[j]
>>
>> Why are you assigning cSQL to the same string over and over again?
> 
> I like it in cloxe proximity to the vals statement.

The line immediately above the loop is in close proximity. Is that not close
enough?


>> Sure, assignments are cheap, but they're not infinitely cheap. They still
>> have a cost. Instead of paying that cost once, you pay it over and over
>> again, which adds up.
> 
> Adds up to what?

Potentially a significant waste of time. You know what they say about
financial waste: "a million here, a million there, and soon we're talking
about real money".

The first point is that this is a micro-pessimisation: even though it
doesn't cost much individually, its still a needless expense that your
program keeps paying. Its like friction on your code.

Python is neither the fastest nor the slowest language available. It is
often "fast enough", but it is also an easy language to write slow code in.
If you were programming in C, the compiler would almost surely see that the
assignment was to a constant, and automatically and silently hoist it
outside the loop. That's one reason why C is so fast: it aggressively
optimizes your code. (Too aggressively, in my opinion, but that's another
story.) But the Python compiler isn't that sophisticated. It's up to us,
the programmers, to be mindful of the friction we add to our code, because
if we aren't mindful of it, we can easily end up with needlessly slow code.

But as I said, that's not the major problem with doing the assignment in the
loop. It's more about readability and your reader's expectations than the
extra time it costs.


>> Worse, it is misleading. I had to read that code snippet three or four
>> times before I realised that cSQL was exactly the same each time.
> 
> You had to read 5 words three or four times?   Seriously?

Yes, seriously, because when most people read code they skim it, speed
reading, looking for salient points of interest. They don't point their
finger under each word and read it aloud syllable by syllable like a
pre-schooler with reading difficulties. (At least I don't, I can't speak
for others.) So the first couple of times I glanced at it, it just looked
like any other assignment without the details registering.

Then the next couple of times I thought that it must be *me* making the
mistake, I must be reading it wrong. Maybe there's something I missed? I
read code with the default assumption that it is more or less sensible.

Over the various posts and replies to posts, I had probably glanced at that
line a dozen times, and then read it more carefully three or four times,
before I was sure I had read what I thought I had read.


[...]
> I like mine best of all:
> 
> ziplists = zip(names,streets,cities,states,zipcodes)
> for name,street,city,state,zipcode in ziplists:

Using a temporary, single-use variable is okay, but it's often unnecessary.

But be aware that there is a particular risk with loops. You may be tempted
to think you can re-use ziplists to iterate over it twice:

data = zip(names, streets, cities, states, zipcodes)
for a, b, c in data:
do_stuff()
...
# later
for x, y, z in data:
do_something_else()

and that's perfectly fine, *but* there is a risk that if the for loop data
being iterated over is an iterator, it will have been exhausted by the
first loop and the second loop won't run at all.

In Python 2, zip() returns a list, but in Python 3, it returns an iterator.
So beware of using such temp variables unless you know what you're doing.


>>> I like the first one better.  python is awesome, but too many options
>>> for doing the same thing also makes it difficult.  For me, anyway.
>>
>>
>> That's the difference between a master and an apprentice. The apprentice
>> likes to follow fixed steps the same way each time. The master craftsman
>> knows her tools backwards, and can choose the right tool for the job, and
>> when the choice of tool really doesn't matter and you can use whatever
>> happens to be the closest to hand.
> 
> "her tools"... you're a woman?

What makes you think I was talking about myself? I was talking about people
in general -- when we are beginners, its only natural that (like most
beginners) we're more comfortable with a limited amount of choice. Its hard
to remember what option to use when there's only one, let alone when
there's ten. But as we progress to mastery of the language, we'll come to
understand the subtle differences between options, when they matter, and
when they don't.

If I had said "his tools", would you have thought I was talking specifically
about a man?

Does it matter if I'm a woman? Would that make my advice better or worse?




-- 
Steven

-- 
https://mail.python.org/m

Re: pylint woes

2016-05-08 Thread DFS

On 5/8/2016 9:17 PM, Gregory Ewing wrote:

Stephen Hansen wrote:

The point is, you don't usually commit after an error happens. You
rollback.


He might want to commit the ones that *did* go in.
That's not necessarily wrong. It all depends on the
surrounding requirements and workflow.


Bingo.


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


Re: String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?)

2016-05-08 Thread Chris Angelico
On Mon, May 9, 2016 at 10:44 AM, Thomas 'PointedEars' Lahn
 wrote:
> With the “%” string operator (deprecated), str.format(), and str.Template,
> you can use other values in string values even without concatenation.

Not deprecated. Don't spread FUD.

> Finally, with SQL you should prefer Prepared Statements and Stored
> Procedures, not bare strings, to avoid SQL injection:
>
> 

He is safe. He's using parameterized queries.

> Also, it would be a good idea if you posted under your real name.  Internet
> is the thing with cables; Usenet is the thing with people.  I for one tend
> to avoid communicating with few-letter entities; exceptions to that would
> probably include only E.T., M.J., ALF, and K.I.T.T.

I'm not using Usenet, Mr PointedEars.

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


Re: pylint woes

2016-05-08 Thread Chris Angelico
On Mon, May 9, 2016 at 11:17 AM, Gregory Ewing
 wrote:
> Stephen Hansen wrote:
>>
>> The point is, you don't usually commit after an error happens. You
>> rollback.
>
>
> He might want to commit the ones that *did* go in.
> That's not necessarily wrong. It all depends on the
> surrounding requirements and workflow.

If that's the case, they should probably be being committed part way.
Generally, once the transaction state is in error, further operations
can't be done. (At least, that's how it is with *good* database
backends. I don't know what MySQL does.)

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


Re: pylint woes

2016-05-08 Thread Larry Hudson via Python-list

On 05/08/2016 03:07 PM, Chris Angelico wrote:

On Mon, May 9, 2016 at 6:45 AM, Larry Hudson via Python-list
 wrote:

On 05/08/2016 06:01 AM, Chris Angelico wrote:
[snip...]


...  I like to recommend a
little thing called "IIDPIO debugging" - If In Doubt, Print It Out.
That means: If you have no idea what a piece of code is doing, slap in
a print() call somewhere. It'll tell you that (a) the code is actually
being executed, and (b) whatever info you put between the parens
(ideally, some key variable or parameter)...



My personal variation of IIPPID debugging is to use input() instead of
print().  For example:

 input('x = {}, y = {} --> '.format(x, y))

Then the program stops at this point so you can examine the values.  
will continue the program or ^C will abort (if you see what the problem is
now).  Of course this can't be used in all situations, but it's handy where
it can.

Note that my personal preference is to stick that "-->" as a prompt at the
end, but obviously this (or a similar marker) is optional.


Neat technique. Not something to use *every* time (and not always
sensible - eg you don't normally want to stall out a GUI thread), but
definitely worth keeping in the arsenal.

ChrisA



Agreed.  As I said in my post, it is certainly not a universally valid approach, but I do find 
it useful in many cases.


 -=- Larry -=-

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


Re: pylint woes

2016-05-08 Thread Gregory Ewing

Stephen Hansen wrote:

The point is, you don't usually commit after an error happens. You
rollback.


He might want to commit the ones that *did* go in.
That's not necessarily wrong. It all depends on the
surrounding requirements and workflow.

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


String concatenation (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?)

2016-05-08 Thread Thomas 'PointedEars' Lahn
DFS wrote:

> sSQL =  "line 1\n"
> sSQL += "line 2\n"
> sSQL += "line 3"

What is wrong with it in Python is that it is unnecessarily inefficient.  
Python has implicit string concatenation if all operands are string 
literals:

#---
sSQL = ("line 1\n"
"line 2\n"
"line 3")
#---

Alternatively, you can join a list of strings:

#---
sSQL = "\n".join([
 "line 1",
 "line 2",
 "line 3",
   ])
#---

Python also has a way that avoids using several string literals:

#---
  sSQL =  """line 1
line 2
line 3"""
#---

or (to have the text aligned)

#---
  sSQL = """\
line 1
line 2
line 3"""
#---

With the “%” string operator (deprecated), str.format(), and str.Template, 
you can use other values in string values even without concatenation.

Next time, RTFM first:

 p.

Finally, with SQL you should prefer Prepared Statements and Stored 
Procedures, not bare strings, to avoid SQL injection:




And if you want to communicate only with a specific person, I strongly 
suggest you send *them* an *e-mail* instead of to the newsgroup/mailing 
list.

Also, it would be a good idea if you posted under your real name.  Internet 
is the thing with cables; Usenet is the thing with people.  I for one tend 
to avoid communicating with few-letter entities; exceptions to that would 
probably include only E.T., M.J., ALF, and K.I.T.T.

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?

2016-05-08 Thread Joel Goldstick
On Sun, May 8, 2016 at 7:10 PM, DFS  wrote:
> sSQL =  "line 1\n"
> sSQL += "line 2\n"
> sSQL += "line 3"
> --
> https://mail.python.org/mailman/listinfo/python-list

What is your point DFS?  You found pylint, and you don't like what it
tells you.  Its a tool, and it can tell you some things.  Your code
seems to be a mix of tabs and spaces, and you don't like standard
python practices.  That's fine, coding is (at least alone) an
individual pursuit.  You can code anyway you like.

But, learning from the work of others, can be awfully useful.  Most
people I know use spaces, they set their text editor up to make tabs
turn into 4 spaces.  Problem solved.  As far as wanting to put several
statements on a line, you can do that if you like, but others have
concluded that the code is easier to read if you don't.  If that isn't
your view, do what you like.

It depends upon what problems you want to fight.  If you adhere to
standards, your code is more easily reviewed and easier to get help
from others, if that is what you ask.

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


Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?

2016-05-08 Thread Tim Chase
While I'm not Steven...

On 2016-05-08 19:10, DFS wrote:
> sSQL =  "line 1\n"
> sSQL += "line 2\n"
> sSQL += "line 3"

If you're only doing it once, it's adequate.

If you're doing it within a loop

  for thing in some_iter():
s = "line1\n"
s += "line2\n"
s += "line3"
use(s, thing)

it's suboptimal.  Solutions include hoisting it out of the loop:

  s = "line1\n"
  s += "line2\n"
  s += "line3"
  for thing in some_iter():
use(s, thing)

and just specifying it with a multi-line string (still better off
hoisted out of the loop):

  s = """line1
line2
line3"""
  for thing in some_iter():
use(s, thing)

If you're accruing in a loop

  s = ""
  for thing in some_iter():
s += mung(thing)

then that's a bad code-smell (you get quadratic behavior as the
strings are constantly resized), usually better replaced with

  s = "".join(mung(thing) for thing in some_iter())

or build them up as a list, then join the results:

  lst = []
  for thing in some_iter():
if should_use(thing):
  lst.append(thing)
  s = "\n".join(lst)

-tkc




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


Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?

2016-05-08 Thread DFS

sSQL =  "line 1\n"
sSQL += "line 2\n"
sSQL += "line 3"
--
https://mail.python.org/mailman/listinfo/python-list


Re: pylint woes

2016-05-08 Thread DFS

On 5/8/2016 6:05 PM, Stephen Hansen wrote:

On Sun, May 8, 2016, at 02:46 PM, DFS wrote:

On 5/8/2016 5:38 PM, Stephen Hansen wrote:

On Sun, May 8, 2016, at 02:16 PM, DFS wrote:

I was surprised to see the PEP8 guide approve of:

"Yes: if x == 4: print x, y; x, y = y, x"

https://www.python.org/dev/peps/pep-0008/#pet-peeves


That is not approving of that line of code as something to mimic, its
speaking *only* about *whitespace*.

ALL its saying is, "don't put spaces before commas, colons or
semicolons". You can infer nothing else about it.


I can infer that it's 100% approved of, since he used it as an example.


Not if you don't want to be a fool.


Why would you label the author of that style guide - Guido van Rossum - 
a fool?






And at this point I'm signing out from helping you.



A fool and a fool are soon parted.




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


Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Chris Angelico
On Mon, May 9, 2016 at 3:48 AM, Tim Chase  wrote:
> On ⅯⅯⅩⅥ-Ⅴ-Ⅷ Ⅹ:ⅩⅩⅤ, Christopher Reimer wrote:
>>> Closing line: "In America today, the only thing more terrifying
>>> than foreigners is...math."
>>> Wonder how close to terrorists pythonists are
>>
>> I wonder how many Americans are aware that they use Hindu-Arabic
>> numerals in daily transactions?
>
> There must be Ⅽ good reasons not to succumb to those "terrorist"
> numerals.  I can name Ⅰ or Ⅱ other numeric systems that are just as
> useful. ;-)

Hands up those of you who are fluent in Latin. *looks around* Hmm, a
couple! More than I thought.

Hands up those of you who've written Python scripts. Yep, good, good,
now I know you're all awake, at least.

Now, hands up those who've used Latin script.

Hmm, curious.

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


Re: pylint woes

2016-05-08 Thread Chris Angelico
On Mon, May 9, 2016 at 6:49 AM, Dan Sommers  wrote:
> On Sun, 08 May 2016 23:01:55 +1000, Chris Angelico wrote:
>
>> ... I like to recommend a little thing called "IIDPIO debugging" - If
>> In Doubt, Print It Out.  That means: If you have no idea what a piece
>> of code is doing, slap in a print() call somewhere. It'll tell you
>> that (a) the code is actually being executed, and (b) whatever info
>> you put between the parens (ideally, some key variable or
>> parameter). Part A is often the important bit :) ...
>
> Having spent a long time developing embedded systems, I wholeheartedly
> agree.  In spirit.  Isn't that what the logging module is for?  Fine
> grained control, as centralized or distributed as is warranted, over
> program output?
>
>> ... The trouble with a verbose flag controlling all print() calls is
>> that IIDPIO debugging suddenly doesn't work; plus, it's easy to copy
>> and paste code to some other module and not notice that you don't have
>> a verbosity check at the top, and then wonder why disabling verbose
>> doesn't fully work. Both problems are solved by having a dedicated
>> spam function, which will simply error out if you didn't set it up
>> properly.
>
> Hey!  That sounds just like the logging module  ;-)

Absolutely. I say "print" in IIDPIO because it's a word that people
understand across languages, across frameworks, etc, etc, but when you
start doing more of it, the logging module is definitely superior - if
you need just one reason to use it, it would be to *leave those prints
in place* so the next person doesn't need to reach for IIDPIO at all.

(Also, I teach print() because it's one less module to explain. But
experienced programmers should get some familiarity with it.)

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


Re: pylint woes

2016-05-08 Thread Chris Angelico
On Mon, May 9, 2016 at 6:45 AM, Larry Hudson via Python-list
 wrote:
> On 05/08/2016 06:01 AM, Chris Angelico wrote:
> [snip...]
>>
>> ...  I like to recommend a
>> little thing called "IIDPIO debugging" - If In Doubt, Print It Out.
>> That means: If you have no idea what a piece of code is doing, slap in
>> a print() call somewhere. It'll tell you that (a) the code is actually
>> being executed, and (b) whatever info you put between the parens
>> (ideally, some key variable or parameter)...
>
>
> My personal variation of IIPPID debugging is to use input() instead of
> print().  For example:
>
> input('x = {}, y = {} --> '.format(x, y))
>
> Then the program stops at this point so you can examine the values.  
> will continue the program or ^C will abort (if you see what the problem is
> now).  Of course this can't be used in all situations, but it's handy where
> it can.
>
> Note that my personal preference is to stick that "-->" as a prompt at the
> end, but obviously this (or a similar marker) is optional.

Neat technique. Not something to use *every* time (and not always
sensible - eg you don't normally want to stall out a GUI thread), but
definitely worth keeping in the arsenal.

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


Re: pylint woes

2016-05-08 Thread Stephen Hansen
On Sun, May 8, 2016, at 02:46 PM, DFS wrote:
> On 5/8/2016 5:38 PM, Stephen Hansen wrote:
> > On Sun, May 8, 2016, at 02:16 PM, DFS wrote:
> >> I was surprised to see the PEP8 guide approve of:
> >>
> >> "Yes: if x == 4: print x, y; x, y = y, x"
> >>
> >> https://www.python.org/dev/peps/pep-0008/#pet-peeves
> >
> > That is not approving of that line of code as something to mimic, its
> > speaking *only* about *whitespace*.
> >
> > ALL its saying is, "don't put spaces before commas, colons or
> > semicolons". You can infer nothing else about it.
> 
> I can infer that it's 100% approved of, since he used it as an example.

Not if you don't want to be a fool.

And at this point I'm signing out from helping you.

-- 
Stephen Hansen
  m e @ i x o k a i . i o
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pylint woes

2016-05-08 Thread DFS

On 5/8/2016 5:38 PM, Stephen Hansen wrote:

On Sun, May 8, 2016, at 02:16 PM, DFS wrote:

I was surprised to see the PEP8 guide approve of:

"Yes: if x == 4: print x, y; x, y = y, x"

https://www.python.org/dev/peps/pep-0008/#pet-peeves


That is not approving of that line of code as something to mimic, its
speaking *only* about *whitespace*.

ALL its saying is, "don't put spaces before commas, colons or
semicolons". You can infer nothing else about it.



I can infer that it's 100% approved of, since he used it as an example.




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


Re: pylint woes

2016-05-08 Thread Joel Goldstick
On Sun, May 8, 2016 at 5:24 PM, DFS  wrote:
> On 5/8/2016 7:36 AM, Steven D'Aprano wrote:
>>
>> On Sun, 8 May 2016 11:16 am, DFS wrote:
>>
>>> address data is scraped from a website:
>>>
>>> names = tree.xpath()
>>> addr  = tree.xpath()
>>
>>
>> Why are you scraping the data twice?
>
>
>
> Because it exists in 2 different sections of the document.
>
> names = tree.xpath('//span[@class="header_text3"]/text()')
> addresses = tree.xpath('//span[@class="text3"]/text()')
>
>
> I thought you were a "master who knew her tools", and I was the apprentice?
>
> So why did "the master" think xpath() was magic?
>
>
>
>
>
>
>> names = addr = tree.xpath()
>>
>> or if you prefer the old-fashioned:
>>
>> names = tree.xpath()
>> addr = names
>>
>> but that raises the question, how can you describe the same set of data as
>> both "names" and "addr[esses]" and have them both be accurate?
>>
>>
>>> I want to store the data atomically,
>>
>>
>> I'm not really sure what you mean by "atomically" here. I know what *I*
>> mean
>> by "atomically", which is to describe an operation which either succeeds
>> entirely or fails.
>
>
> That's atomicity.
>
>
>
>> But I don't know what you mean by it.
>
> http://www.databasedesign-resource.com/atomic-database-values.html
>
>
>
>>> so I parse street, city, state, and
>>> zip into their own lists.
>>
>>
>> None of which is atomic.
>
>
> All of which are atomic.
>
>
>
>>> "1250 Peachtree Rd, Atlanta, GA 30303
>>>
>>> street = [s.split(',')[0] for s in addr]
>>> city   = [c.split(',')[1].strip() for c in addr]
>>> state  = [s[-8:][:2] for s in addr]
>>> zipcd  = [z[-5:] for z in addr]
>>
>>
>> At this point, instead of iterating over the same list four times, doing
>> the
>> same thing over and over again, you should do things the old-fashioned
>> way:
>>
>> streets, cities, states, zipcodes = [], [], [], []
>> for word in addr:
>> items = word.split(',')
>> streets.append(items[0])
>> cities.append(items[1].strip())
>> states.append(word[-8:-2])
>> zipcodes.append(word[-5:])
>
>
>
>
> That's a good one.
>
> Chris Angelico mentioned something like that, too, and I already put it
> place.
>
>
>
>> Oh, and use better names. "street" is a single street, not a list of
>> streets, note plural.
>
>
>
> I'll use whatever names I like.
>
>
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list

Starting to look like trolling.  Lots of good advice here.  If you
ask, and don't like the advice, don't use it.
-- 
Joel Goldstick
http://joelgoldstick.com/blog
http://cc-baseballstats.info/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pylint woes

2016-05-08 Thread Stephen Hansen
On Sun, May 8, 2016, at 02:16 PM, DFS wrote:
> I was surprised to see the PEP8 guide approve of:
> 
> "Yes: if x == 4: print x, y; x, y = y, x"
> 
> https://www.python.org/dev/peps/pep-0008/#pet-peeves

That is not approving of that line of code as something to mimic, its
speaking *only* about *whitespace*.

ALL its saying is, "don't put spaces before commas, colons or
semicolons". You can infer nothing else about it.

-- 
Stephen Hansen
  m e @ i x o k a i . i o
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pylint woes

2016-05-08 Thread DFS

On 5/8/2016 7:36 AM, Steven D'Aprano wrote:

On Sun, 8 May 2016 11:16 am, DFS wrote:


address data is scraped from a website:

names = tree.xpath()
addr  = tree.xpath()


Why are you scraping the data twice?



Because it exists in 2 different sections of the document.

names = tree.xpath('//span[@class="header_text3"]/text()')
addresses = tree.xpath('//span[@class="text3"]/text()')


I thought you were a "master who knew her tools", and I was the 
apprentice?


So why did "the master" think xpath() was magic?







names = addr = tree.xpath()

or if you prefer the old-fashioned:

names = tree.xpath()
addr = names

but that raises the question, how can you describe the same set of data as
both "names" and "addr[esses]" and have them both be accurate?



I want to store the data atomically,


I'm not really sure what you mean by "atomically" here. I know what *I* mean
by "atomically", which is to describe an operation which either succeeds
entirely or fails.


That's atomicity.



> But I don't know what you mean by it.

http://www.databasedesign-resource.com/atomic-database-values.html




so I parse street, city, state, and
zip into their own lists.


None of which is atomic.


All of which are atomic.




"1250 Peachtree Rd, Atlanta, GA 30303

street = [s.split(',')[0] for s in addr]
city   = [c.split(',')[1].strip() for c in addr]
state  = [s[-8:][:2] for s in addr]
zipcd  = [z[-5:] for z in addr]


At this point, instead of iterating over the same list four times, doing the
same thing over and over again, you should do things the old-fashioned way:

streets, cities, states, zipcodes = [], [], [], []
for word in addr:
items = word.split(',')
streets.append(items[0])
cities.append(items[1].strip())
states.append(word[-8:-2])
zipcodes.append(word[-5:])




That's a good one.

Chris Angelico mentioned something like that, too, and I already put it 
place.





Oh, and use better names. "street" is a single street, not a list of
streets, note plural.



I'll use whatever names I like.





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


Re: pylint woes

2016-05-08 Thread DFS

On 5/8/2016 1:25 PM, Steven D'Aprano wrote:

On Sun, 8 May 2016 02:10 pm, DFS wrote:




+-++
|bad-whitespace   |65  | mostly because I line up =
  signs:
  var1  = value
  var10 = value


Yuck. How much time do you waste aligning assignments whenever you add or
delete or edit a variable?


Lots.  It takes hours to add or delete 3 whitespaces.


Yes, you're right. It takes you five minutes to line everything up the first
time. Then you change the name of a variable, and now you have to realign
everything -- that's an extra minute gone. Then you add another line, and
have to realign again, another couple of minutes. Over the lifespan of the
program, you'll probably have spent multiple hours wasting time realigning
blocks of assignments.



Do you actually believe what you just wrote?

If yes, you should quit programming.

If not, why did you say it?








+-++
|trailing-whitespace  |59  | heh!
+-++
|multiple-statements  |23  | do this to save lines.
  Will continue doing it.


Why? Do you think that there's a world shortage of newline characters? Is
the Enter key on your keyboard broken?


I do it because I like it.

if verbose: print var

python doesn't complain.


Hmmm. Well, that's not too bad. I thought you mean something like:

addr = getaddress(key); addr[2] = addr.upper(); print addr

which is just horrible.



I was surprised to see the PEP8 guide approve of:

"Yes: if x == 4: print x, y; x, y = y, x"

https://www.python.org/dev/peps/pep-0008/#pet-peeves







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


Re: pylint woes

2016-05-08 Thread DFS

On 5/8/2016 11:15 AM, Chris Angelico wrote:

On Mon, May 9, 2016 at 1:06 AM, DFS  wrote:

On 5/8/2016 10:36 AM, Chris Angelico wrote:


On Mon, May 9, 2016 at 12:25 AM, DFS  wrote:


for category,name,street,city,state,zipcode in ziplists:
  try: db.execute(cSQL, vals)
  except (pyodbc.Error) as programError:
   if str(programError).find("UNIQUE constraint failed") > 0:
dupeRow = True
dupes +=1
print " * duplicate address found: "+name+", "+street
   else:
pyodbcErr = True
print "ODBC error: %s " % programError
conn.commit()




... and then you just commit???!?

ChrisA




That's what commit() does.


Yes. Even if you got an error part way through, you just blithely commit. What?!

And yes, I am flat-out boggling at this.

ChrisA



I'm boggling that you're boggling.




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


Re: pylint woes

2016-05-08 Thread DFS

On 5/7/2016 2:43 PM, Peter Pearson wrote:

On Sat, 7 May 2016 12:51:00 -0400, DFS  wrote:

This more-anal-than-me program generated almost 2 warnings for every
line of code in my program.  w t hey?


Thank you for putting a sample of pylint output in front of my eyes;
you inspired me to install pylint and try it out.  If it teaches me even
half as much as it's teaching you, I'll consider it a great blessing.


Cool.

I don't agree with some of them, but there's no doubt adhering to them 
will result in more well-formed code.



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


Re: pylint woes

2016-05-08 Thread DFS

On 5/8/2016 11:51 AM, Steven D'Aprano wrote:

On Mon, 9 May 2016 12:25 am, DFS wrote:


for j in range(len(nms)):
 cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)"
 vals = nms[j],street[j],city[j],state[j],zipcd[j]


Why are you assigning cSQL to the same string over and over again?


I like it in cloxe proximity to the vals statement.



Sure, assignments are cheap, but they're not infinitely cheap. They still
have a cost. Instead of paying that cost once, you pay it over and over
again, which adds up.


Adds up to what?




Worse, it is misleading. I had to read that code snippet three or four times
before I realised that cSQL was exactly the same each time.


You had to read 5 words three or four times?   Seriously?




I tried:

for nm,street,city,state,zipcd in zip(nms,street,city,state,zipcd):

but felt it was too long and wordy.


It's long and wordy because you're doing something long and wordy. It is
*inherently* long and wordy to process five things, whether you write it
as:

for i in range(len(names)):
name = names[i]
street = streets[i]
city = cities[i]
state = states[i]
zipcode = zipcodes[i]
process(...)

or as:

for name, street, city, state, zipcode in zip(
names, streets, cities, states, zipcodes
):
process(...)



I like mine best of all:

ziplists = zip(names,streets,cities,states,zipcodes)
for name,street,city,state,zipcode in ziplists:




I like the first one better.  python is awesome, but too many options
for doing the same thing also makes it difficult.  For me, anyway.



That's the difference between a master and an apprentice. The apprentice
likes to follow fixed steps the same way each time. The master craftsman
knows her tools backwards, and can choose the right tool for the job, and
when the choice of tool really doesn't matter and you can use whatever
happens to be the closest to hand.


"her tools"... you're a woman?



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


Re: pylint woes

2016-05-08 Thread Dan Sommers
On Sun, 08 May 2016 23:01:55 +1000, Chris Angelico wrote:

> ... I like to recommend a little thing called "IIDPIO debugging" - If
> In Doubt, Print It Out.  That means: If you have no idea what a piece
> of code is doing, slap in a print() call somewhere. It'll tell you
> that (a) the code is actually being executed, and (b) whatever info
> you put between the parens (ideally, some key variable or
> parameter). Part A is often the important bit :) ...

Having spent a long time developing embedded systems, I wholeheartedly
agree.  In spirit.  Isn't that what the logging module is for?  Fine
grained control, as centralized or distributed as is warranted, over
program output?

> ... The trouble with a verbose flag controlling all print() calls is
> that IIDPIO debugging suddenly doesn't work; plus, it's easy to copy
> and paste code to some other module and not notice that you don't have
> a verbosity check at the top, and then wonder why disabling verbose
> doesn't fully work. Both problems are solved by having a dedicated
> spam function, which will simply error out if you didn't set it up
> properly.

Hey!  That sounds just like the logging module  ;-)

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


Re: pylint woes

2016-05-08 Thread Larry Hudson via Python-list

On 05/08/2016 06:01 AM, Chris Angelico wrote:
[snip...]

...  I like to recommend a
little thing called "IIDPIO debugging" - If In Doubt, Print It Out.
That means: If you have no idea what a piece of code is doing, slap in
a print() call somewhere. It'll tell you that (a) the code is actually
being executed, and (b) whatever info you put between the parens
(ideally, some key variable or parameter)...


My personal variation of IIPPID debugging is to use input() instead of print(). 
 For example:

input('x = {}, y = {} --> '.format(x, y))

Then the program stops at this point so you can examine the values.   will continue the 
program or ^C will abort (if you see what the problem is now).  Of course this can't be used in 
all situations, but it's handy where it can.


Note that my personal preference is to stick that "-->" as a prompt at the end, but obviously 
this (or a similar marker) is optional.


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


Re: Python PygLatin

2016-05-08 Thread Christopher Reimer

On 5/8/2016 10:53 AM, alister wrote:

On Mon, 09 May 2016 03:12:14 +1000, Steven D'Aprano wrote:


On Sun, 8 May 2016 08:21 pm, Cai Gengyang wrote:


If one looks at the Forbes List, you will see that there are 4
programmers amongst the top ten richest people in the world (Bill
Gates, Mark Zuckerberg, Larry Ellison and Jeff Bezos) , a very large
percentage. Science and Technology is in a sense the most egalitarian
field in the world, because it involves using your brains and
creativity. You don't need to have a father who is a director at
Goldman Sachs or a mother who is the admissions officer at Harvard to
succeed in this line.

Bill Gates III's father was a prominent lawyer, his mother was on the
board of directors for First Interstate BancSystem and United Way, and
one of his grandfathers was a national bank president. Gates himself
went to Harvard.

Zuckerberg's paternal grandparents were successful middle class,
described as  being the first on the block to own a colour TV. (This was
back in the days when colour TVs were an expensive toy that few could
afford.) His parents were also very successful professionals: a dentist
and a psychiatrist. And he too went to Harvard. Despite the jeans and
tee-shirts Zuckerberg is known for wearing, he's firmly from the
professional/upper class.

Bezos comes from a family of land-holders from Texas. His grandfather
was regional director of the U.S. Atomic Energy Commission, and was
financially successful enough to retire at an early age. He didn't go to
Harvard, but he did go to Princeton.

Ellison is the son of an unwed mother who gave him up for adoption by
her aunt and uncle, comfortably middle-class. That makes him the closest
out of the group as a "regular guy".

And at least 2 of the above reached their position using business
practices that could be described as less than 100% honorable & above
board.


What do you expect from people who haven't graduated from Harvard? :P

Thank you,

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


Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Christopher Reimer

On 5/8/2016 9:27 AM, Steven D'Aprano wrote:

On Sun, 8 May 2016 08:22 pm, beliav...@aol.com wrote:


There are
far more female than male teachers. I don't attribute it to anti-male
suppression but to greater female interest in working with children.

Of course there is suppression of male teachers, particularly but not only
for very young children.


A college instructor encouraged me to become a teacher,  especially as 
boys from single mom families needed a daily role model. I looked into 
it and took some preparatory childhood classes. When the local 
university had a presentation for their teacher program, I went, saw how 
sausage got made, and ran like hell.


Thank you,

Chris R.

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


Re: Help for a complex RE

2016-05-08 Thread Peter Otten
Sergio Spina wrote:

> I know about greedy and not-greedy, but the problem remains.

This makes me wonder why you had to ask

>>> Why the regex engine stops the search at last piece of string?
>>> Why not at the first match of the group "@:"?

To make it crystal clear this time:

>>> import re
>>> 
>>> patt = r"""  # the match pattern is:
... .+? # one or more characters
... [ ] # followed by a space
... (?=[@#D]:)  # that is followed by one of the
... # chars "@#D" and a colon ":"
... """
>>> pattern = re.compile(patt, re.VERBOSE)
>>> m = pattern.match("Jun@i Bun#i @:Janji D:Banji #:Junji")
>>> m.group()
'Jun@i Bun#i '

That's exactly what you asked for in

>>> What can it be a regex pattern with the following result?
>>> 
 In [1]: m = pattern.match("Jun@i Bun#i @:Janji D:Banji #:Junji")
 
 In [2]: m.group()
 Out[2]: 'Jun@i Bun#i '

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


Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Tim Chase
On ⅯⅯⅩⅥ-Ⅴ-Ⅷ Ⅹ:ⅩⅩⅤ, Christopher Reimer wrote:
>> Closing line: "In America today, the only thing more terrifying
>> than foreigners is...math."
>> Wonder how close to terrorists pythonists are
> 
> I wonder how many Americans are aware that they use Hindu-Arabic 
> numerals in daily transactions?

There must be Ⅽ good reasons not to succumb to those "terrorist"
numerals.  I can name Ⅰ or Ⅱ other numeric systems that are just as
useful. ;-)

-tkc






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


Re: Python PygLatin

2016-05-08 Thread alister
On Mon, 09 May 2016 03:12:14 +1000, Steven D'Aprano wrote:

> On Sun, 8 May 2016 08:21 pm, Cai Gengyang wrote:
> 
>> If one looks at the Forbes List, you will see that there are 4
>> programmers amongst the top ten richest people in the world (Bill
>> Gates, Mark Zuckerberg, Larry Ellison and Jeff Bezos) , a very large
>> percentage. Science and Technology is in a sense the most egalitarian
>> field in the world, because it involves using your brains and
>> creativity. You don't need to have a father who is a director at
>> Goldman Sachs or a mother who is the admissions officer at Harvard to
>> succeed in this line.
> 
> Bill Gates III's father was a prominent lawyer, his mother was on the
> board of directors for First Interstate BancSystem and United Way, and
> one of his grandfathers was a national bank president. Gates himself
> went to Harvard.
> 
> Zuckerberg's paternal grandparents were successful middle class,
> described as  being the first on the block to own a colour TV. (This was
> back in the days when colour TVs were an expensive toy that few could
> afford.) His parents were also very successful professionals: a dentist
> and a psychiatrist. And he too went to Harvard. Despite the jeans and
> tee-shirts Zuckerberg is known for wearing, he's firmly from the
> professional/upper class.
> 
> Bezos comes from a family of land-holders from Texas. His grandfather
> was regional director of the U.S. Atomic Energy Commission, and was
> financially successful enough to retire at an early age. He didn't go to
> Harvard, but he did go to Princeton.
> 
> Ellison is the son of an unwed mother who gave him up for adoption by
> her aunt and uncle, comfortably middle-class. That makes him the closest
> out of the group as a "regular guy".

And at least 2 of the above reached their position using business 
practices that could be described as less than 100% honorable & above 
board.




-- 
Wait ... is this a FUN THING or the END of LIFE in Petticoat Junction??
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pylint woes

2016-05-08 Thread Steven D'Aprano
On Sun, 8 May 2016 02:10 pm, DFS wrote:

> I mean I always use tab after :
> 
> The program won't run otherwise.  If I use spaces, 100% of the time it
> throws:
> 
> IndentationError: unindent does not match any outer indentation level

Then you should be more careful about your spaces. If you indent by four
spaces, you have to outdent by four -- not three, not five, but four.

The best way to do this is to use an editor that will count the spaces for
you. Any decent programmer's editor will allow you to set the TAB key to
indent by X spaces, and the Shift-TAB key to dedent by the same amount. If
you're counting spaces yourself, you're just making more work for yourself.

Or use tabs -- that's acceptable as well.

Just don't mix tabs and spaces in the same file.


>>> +-++
>>> |bad-whitespace   |65  | mostly because I line up =
>>>   signs:
>>>   var1  = value
>>>   var10 = value
>>
>> Yuck. How much time do you waste aligning assignments whenever you add or
>> delete or edit a variable?
> 
> Lots.  It takes hours to add or delete 3 whitespaces.

Yes, you're right. It takes you five minutes to line everything up the first
time. Then you change the name of a variable, and now you have to realign
everything -- that's an extra minute gone. Then you add another line, and
have to realign again, another couple of minutes. Over the lifespan of the
program, you'll probably have spent multiple hours wasting time realigning
blocks of assignments.


>>> +-++
>>> |trailing-whitespace  |59  | heh!
>>> +-++
>>> |multiple-statements  |23  | do this to save lines.
>>>   Will continue doing it.
>>
>> Why? Do you think that there's a world shortage of newline characters? Is
>> the Enter key on your keyboard broken?
> 
> I do it because I like it.
> 
> if verbose: print var
> 
> python doesn't complain.

Hmmm. Well, that's not too bad. I thought you mean something like:

addr = getaddress(key); addr[2] = addr.upper(); print addr

which is just horrible.




-- 
Steven

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


Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Christopher Reimer

On 5/8/2016 8:09 AM, Rustom Mody wrote:

See:
https://www.washingtonpost.com/news/rampage/wp/2016/05/07/ivy-league-economist-interrogated-for-doing-math-on-american-airlines-flight/

Closing line: "In America today, the only thing more terrifying than foreigners 
is...math."


Wonder how close to terrorists pythonists are


I wonder how many Americans are aware that they use Hindu-Arabic 
numerals in daily transactions?


https://en.wikipedia.org/wiki/Hindu%E2%80%93Arabic_numeral_system

Thank you,

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


Re: Help for a complex RE

2016-05-08 Thread Terry Reedy

On 5/8/2016 12:32 PM, Sergio Spina wrote:

Il giorno domenica 8 maggio 2016 18:16:56 UTC+2, Peter Otten ha scritto:

Sergio Spina wrote:


In the following ipython session:


Python 3.5.1+ (default, Feb 24 2016, 11:28:57)
Type "copyright", "credits" or "license" for more information.

IPython 2.3.0 -- An enhanced Interactive Python.

In [1]: import re

In [2]: patt = r"""  # the match pattern is:
...: .+  # one or more characters
...: [ ] # followed by a space
...: (?=[@#D]:)  # that is followed by one of the
...: # chars "@#D" and a colon ":"
...:"""

In [3]: pattern = re.compile(patt, re.VERBOSE)

In [4]: m = pattern.match("Jun@i Bun#i @:Janji")

In [5]: m.group()
Out[5]: 'Jun@i Bun#i '

In [6]: m = pattern.match("Jun@i Bun#i @:Janji D:Banji")

In [7]: m.group()
Out[7]: 'Jun@i Bun#i @:Janji '

In [8]: m = pattern.match("Jun@i Bun#i @:Janji D:Banji #:Junji")

In [9]: m.group()
Out[9]: 'Jun@i Bun#i @:Janji D:Banji '


Why the regex engine stops the search at last piece of string?
Why not at the first match of the group "@:"?
What can it be a regex pattern with the following result?


In [1]: m = pattern.match("Jun@i Bun#i @:Janji D:Banji #:Junji")

In [2]: m.group()
Out[2]: 'Jun@i Bun#i '


Compare:


re.compile("a+").match("").group()

''

re.compile("a+?").match("").group()

'a'

By default pattern matching is "greedy" -- the ".+" part of your regex
matches as many characters as possible. Adding a ? like in ".+?" triggers
non-greedy matching.



 In [2]: patt = r"""  # the match pattern is:
 ...: .+  # one or more characters


Peter meant that you should replace '.+' with '.+?' to get the 
non-greedy match.



 ...: [ ] # followed by a space
 ...: (?=[@#D]:)  # ONLY IF is followed by one of the <<< please note
 ...: # chars "@#D" and a colon ":"
 ...:"""


From the python documentation


 (?=...)
 Matches if ... matches next, but doesn't consume any of the string.
 This is called a lookahead assertion. For example,
 Isaac (?=Asimov) will match 'Isaac ' only if it's followed by 'Asimov'.


I know about greedy and not-greedy, but the problem remains.


Greedy '.+' matches the whole string.  The matcher then back up to find 
a space -- initially the last space.  It then, and only then, checks the 
lookahead assertion.  If that failed, it would back up again.  In your 
examples, it succeeds, and the matcher stops.


--
Terry Jan Reedy

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


Re: Python PygLatin

2016-05-08 Thread Steven D'Aprano
On Sun, 8 May 2016 08:21 pm, Cai Gengyang wrote:

> If one looks at the Forbes List, you will 
> see that there are 4 programmers amongst the top ten richest people in the
> world (Bill Gates, Mark Zuckerberg, Larry Ellison and Jeff Bezos) , a very
> large percentage. Science and Technology is in a sense the most
> egalitarian field in the world, because it involves using your brains and
> creativity. You don't need to have a father who is a director at Goldman
> Sachs or a mother who is the admissions officer at Harvard to succeed in
> this line.

Bill Gates III's father was a prominent lawyer, his mother was on the board
of directors for First Interstate BancSystem and United Way, and one of his
grandfathers was a national bank president. Gates himself went to Harvard.

Zuckerberg's paternal grandparents were successful middle class, described
as  being the first on the block to own a colour TV. (This was back in the
days when colour TVs were an expensive toy that few could afford.) His
parents were also very successful professionals: a dentist and a
psychiatrist. And he too went to Harvard. Despite the jeans and tee-shirts
Zuckerberg is known for wearing, he's firmly from the professional/upper
class.

Bezos comes from a family of land-holders from Texas. His grandfather was
regional director of the U.S. Atomic Energy Commission, and was financially
successful enough to retire at an early age. He didn't go to Harvard, but
he did go to Princeton.

Ellison is the son of an unwed mother who gave him up for adoption by her
aunt and uncle, comfortably middle-class. That makes him the closest out of
the group as a "regular guy".



-- 
Steven

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


Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Christopher Reimer

On 5/7/2016 11:58 PM, Marko Rauhamaa wrote:

Chris Angelico :


So the question is: Do we care about country equality or individual
equality? You can't have both.

That's why there's been a long-standing initiative to split California
into multiple states:

   https://en.wikipedia.org/wiki/Six_Californias>

Each state gets two senate seats, and California, being the most
populous state, suffers.


The Six Californias is a proposal to divide up the 54 electoral votes 
that California has in presidential elections, which is a solidly blue 
state for the Democrats. Half the population lives in the Los Angeles, 
San Francisco and Sacramento regions. Put these three regions into 
separate states, the other three regions will become solidly red states 
for the Republicans and tilt the presidential elections in their favor. 
The proposal is a solution for the underlying problem that the 
California Republican Party has more in common with the endangered 
spotted owl than one-tenth of the US population. It's easier to redraw 
the lines than compete for votes.


Thank you,

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


Re: Pylint prefers list comprehension over filter...

2016-05-08 Thread Christopher Reimer

On 5/8/2016 5:02 AM, Steven D'Aprano wrote:

On Sun, 8 May 2016 08:01 am, Christopher Reimer wrote:


On 5/7/2016 2:22 PM, Chris Angelico wrote:



Also, be sure you read this part of PEP 8:



https://www.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds

Recruiters and hiring managers *are* hobgoblins with with little minds.
And definitely not PEP8-complaint. :)


Do you think that recruiters and hiring managers read your code at all, let
alone that they read it will an eye to PEP 8 compliance?


I meant more than a few technical professionals who got pushed out of 
the job to become recruiters. They tend to ask about everything on the 
resume to poke holes where they can. Each time I tightened the wording 
of my resume whenever they exposed something. If I posted a GitHub link 
on my resume, they *would* check it out. If they know Python, they 
*would* run it.


As for PEP 8 compliance, it was a joke (see the smiley). Laugh, it was 
funny.



No recruiter[1] will do this. No recruiter will even know what PEP 8 is.
They're looking for technical buzzwords ("ten years experience with
Django"), they aren't qualified to judge whether your Django code is good,
bad or indifferent. That's up to the client.


When I used to apply to Linux system admin jobs, the recruiters would 
have a checklist box for the "Red Hat GUI Thing" as an absolute 
requirement. My Linux work experience was exclusively remote command 
line. On the rare occasions that I have used the Linux GUI, I always 
used what got installed as the default GUI for Fedora or Mint.


The first time I said I didn't know what the "Red Hat GUI Thing" was and 
explained that I was fast learner, the recruiter hung up on me. I tried 
to argue with other recruiters that I knew the command line equivalent 
for the GUI. No dice. Some recruiters even accused me of making up 
techno-babble. They all hung up on me. After a dozen phone calls like 
that (all for positions at different companies), I generally stopped 
applying to Linux jobs.


This year I built an inexpensive PC to run Linux and installed the 
current Red Hat Linux. Guess what? The "Red Hat GUI Thing" wasn't 
installed. In fact, the GUI was Gnome by default. According to my 
coworkers, Red Hat started phasing out their own branded GUI several 
years ago. I guess the recruiters haven't gotten the memo yet, as I had 
a phone call about the "Red Hat GUI Thing" last year.



A hiring manager with a technical background might, once you are in
consideration for the job. More likely they will delegate any judgement to
a technical manager, or programmer, who may or may not be a hobgoblin with
a little mind.


Every hiring manager I've ever interviewed with had a technical 
background. The only exception was when the final interview was with the 
marketing director at hardware company. I declined to take the job. If 
you know your Dilbert, it's bad luck when a hardware company is run by 
the marketing department. I wasn't surprised that the company filed 
bankruptcy a few years later.


Thank you,

Chris R.

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


Re: Help for a complex RE

2016-05-08 Thread Sergio Spina
Il giorno domenica 8 maggio 2016 18:16:56 UTC+2, Peter Otten ha scritto:
> Sergio Spina wrote:
> 
> > In the following ipython session:
> > 
> >> Python 3.5.1+ (default, Feb 24 2016, 11:28:57)
> >> Type "copyright", "credits" or "license" for more information.
> >>
> >> IPython 2.3.0 -- An enhanced Interactive Python.
> >>
> >> In [1]: import re
> >>
> >> In [2]: patt = r"""  # the match pattern is:
> >> ...: .+  # one or more characters
> >> ...: [ ] # followed by a space
> >> ...: (?=[@#D]:)  # that is followed by one of the
> >> ...: # chars "@#D" and a colon ":"
> >> ...:"""
> >> 
> >> In [3]: pattern = re.compile(patt, re.VERBOSE)
> >> 
> >> In [4]: m = pattern.match("Jun@i Bun#i @:Janji")
> >> 
> >> In [5]: m.group()
> >> Out[5]: 'Jun@i Bun#i '
> >> 
> >> In [6]: m = pattern.match("Jun@i Bun#i @:Janji D:Banji")
> >> 
> >> In [7]: m.group()
> >> Out[7]: 'Jun@i Bun#i @:Janji '
> >> 
> >> In [8]: m = pattern.match("Jun@i Bun#i @:Janji D:Banji #:Junji")
> >> 
> >> In [9]: m.group()
> >> Out[9]: 'Jun@i Bun#i @:Janji D:Banji '
> > 
> > Why the regex engine stops the search at last piece of string?
> > Why not at the first match of the group "@:"?
> > What can it be a regex pattern with the following result?
> > 
> >> In [1]: m = pattern.match("Jun@i Bun#i @:Janji D:Banji #:Junji")
> >> 
> >> In [2]: m.group()
> >> Out[2]: 'Jun@i Bun#i '
> 
> Compare:
> 
> >>> re.compile("a+").match("").group()
> ''
> >>> re.compile("a+?").match("").group()
> 'a'
> 
> By default pattern matching is "greedy" -- the ".+" part of your regex 
> matches as many characters as possible. Adding a ? like in ".+?" triggers 
> non-greedy matching.

>  In [2]: patt = r"""  # the match pattern is:
>  ...: .+  # one or more characters
>  ...: [ ] # followed by a space
>  ...: (?=[@#D]:)  # ONLY IF is followed by one of the <<< please note
>  ...: # chars "@#D" and a colon ":"
>  ...:""" 

>From the python documentation

>  (?=...)
>  Matches if ... matches next, but doesn't consume any of the string.
>  This is called a lookahead assertion. For example,
>  Isaac (?=Asimov) will match 'Isaac ' only if it's followed by 'Asimov'.

I know about greedy and not-greedy, but the problem remains.

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


Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Steven D'Aprano
On Sun, 8 May 2016 08:22 pm, beliav...@aol.com wrote:

> There are
> far more female than male teachers. I don't attribute it to anti-male
> suppression but to greater female interest in working with children.

Of course there is suppression of male teachers, particularly but not only
for very young children.

http://www.cea-ace.ca/education-canada/article/false-accusations-growing-fear-classroom

http://www.adelaidenow.com.au/news/south-australia/men-too-scared-to-teach-for-fear-of-being-falsely-accused-of-childsex-offences/story-fni6uo1m-1226913910688

http://abcnews.go.com/GMA/Parenting/Story?id=6070282&page=1

Quote:

"I know they're thinking, 'He must be a predator or something. He 
must be some type of pedophile. Why is he in here? He should be 
working for the city, dumping trash, a janitor or something of 
that nature,'" Maiden said.

Not only do parents' gender bias drive men out of teaching, but that same
gender bias influences the choices men make themselves:

- fear of false accusations of being a sexual predator;
- fear of having your sexuality questioned ("looking after kids 
  is women's work");
- low status and pay.

Most men are extremely status-conscious (if often unconsciously) and then
recognise the status (and pay!) of teachers is low:

University lecturers have medium status;
University tutors have less;
High school teachers less again;
Primary school teachers even less;
And pre-school teachers have practical no status.

Basically, the younger the child, the lower the status and the pay.

So most men simply don't even consider it as a job.

Funny the lies we, as a society, tell ourselves. As they say, don't listen
to what people *say* they value, look at what they spend their money on.
Our society says that we value our young kids beyond all price, but we
entrust them into the hands of underpaid, overworked pre-school teachers
who are practically considered drudges. Meanwhile we pay millions of
dollars to over-muscled and under-socialised man-children to chase after a
ball for a few minutes a week.


> In our public middle school (grades 6-8, ages 11-13) there is a
> programming club that is open to girls. My son is shut out because of his
> sex. That is just as wrong as excluding him because of his skin color. I
> oppose such discrimination.

Unless there is a separate programming club for boys, or mixed boys and
girls, so would I. But the mere existence of a girls-only programming club
is not in and of itself discriminatory.

I don't know about programming, but in terms of general schooling:

- on average, boys do better in mixed sex classes than in same sex classes;

- but for girls it is the other way around.


Since boys don't suffer any loss from mixed sex classes, but girls do, it is
common sense to offer girls a same sex option to let them catch up.

Relevant:

http://www.robeastaway.com/blog/boys-versus-girls



-- 
Steven

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


Re: starting docker container messes up terminal settings

2016-05-08 Thread Larry Martell
On Mon, May 2, 2016 at 10:28 AM, Larry Martell  wrote:
> On Mon, May 2, 2016 at 10:08 AM, Joaquin Alzola
>  wrote:
>>>I am starting a docker container from a subprocess.Popen and it works, but 
>>>when the script returns, the terminal settings of my shell are messed up. 
>>>Nothing is echoed and return doesn't cause a >newline. I can fix this with 
>>>'tset' in the terminal, but I don't want to require that. Has anyone here 
>>>worked with docker and had seen and solved this issue?
>>
>> It is good to put part of the code you think is causing the error (Popen 
>> subprocess)
>
> cmd = ['sudo',
>'docker',
>'run',
>'-t',
>'-i',
>'elucidbio/capdata:v2',
>'bash'
> ]
> p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
> stderr=subprocess.STDOUT)

If anyone cares (which is doubtful), I fixed this by removing -t and
passing in stdin=None to Popen.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help for a complex RE

2016-05-08 Thread Peter Otten
Sergio Spina wrote:

> In the following ipython session:
> 
>> Python 3.5.1+ (default, Feb 24 2016, 11:28:57)
>> Type "copyright", "credits" or "license" for more information.
>>
>> IPython 2.3.0 -- An enhanced Interactive Python.
>>
>> In [1]: import re
>>
>> In [2]: patt = r"""  # the match pattern is:
>> ...: .+  # one or more characters
>> ...: [ ] # followed by a space
>> ...: (?=[@#D]:)  # that is followed by one of the
>> ...: # chars "@#D" and a colon ":"
>> ...:"""
>> 
>> In [3]: pattern = re.compile(patt, re.VERBOSE)
>> 
>> In [4]: m = pattern.match("Jun@i Bun#i @:Janji")
>> 
>> In [5]: m.group()
>> Out[5]: 'Jun@i Bun#i '
>> 
>> In [6]: m = pattern.match("Jun@i Bun#i @:Janji D:Banji")
>> 
>> In [7]: m.group()
>> Out[7]: 'Jun@i Bun#i @:Janji '
>> 
>> In [8]: m = pattern.match("Jun@i Bun#i @:Janji D:Banji #:Junji")
>> 
>> In [9]: m.group()
>> Out[9]: 'Jun@i Bun#i @:Janji D:Banji '
> 
> Why the regex engine stops the search at last piece of string?
> Why not at the first match of the group "@:"?
> What can it be a regex pattern with the following result?
> 
>> In [1]: m = pattern.match("Jun@i Bun#i @:Janji D:Banji #:Junji")
>> 
>> In [2]: m.group()
>> Out[2]: 'Jun@i Bun#i '

Compare:

>>> re.compile("a+").match("").group()
''
>>> re.compile("a+?").match("").group()
'a'

By default pattern matching is "greedy" -- the ".+" part of your regex 
matches as many characters as possible. Adding a ? like in ".+?" triggers 
non-greedy matching.

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


Re: [Python-ideas] Boolean parameters guidelines

2016-05-08 Thread Ian Kelly
On May 8, 2016 9:37 AM, "Steven D'Aprano"  wrote:
>
> Not sure why this has migrated to this list instead of Python-Ideas.

Because Gmail has somehow never gotten around to implementing reply-to-list
and I'm terrible at choosing the right one.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pylint woes

2016-05-08 Thread Steven D'Aprano
On Mon, 9 May 2016 12:25 am, DFS wrote:

>>> for j in range(len(nms)):
>>>  cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)"
>>>  vals = nms[j],street[j],city[j],state[j],zipcd[j]

Why are you assigning cSQL to the same string over and over again?

Sure, assignments are cheap, but they're not infinitely cheap. They still
have a cost. Instead of paying that cost once, you pay it over and over
again, which adds up.

Worse, it is misleading. I had to read that code snippet three or four times
before I realised that cSQL was exactly the same each time.


> I tried:
> 
> for nm,street,city,state,zipcd in zip(nms,street,city,state,zipcd):
> 
> but felt it was too long and wordy.

It's long and wordy because you're doing something long and wordy. It is
*inherently* long and wordy to process five things, whether you write it
as:

for i in range(len(names)):
name = names[i]
street = streets[i]
city = cities[i]
state = states[i]
zipcode = zipcodes[i]
process(...)

or as:

for name, street, city, state, zipcode in zip(
names, streets, cities, states, zipcodes
):
process(...)



> I like the first one better.  python is awesome, but too many options
> for doing the same thing also makes it difficult.  For me, anyway.


That's the difference between a master and an apprentice. The apprentice
likes to follow fixed steps the same way each time. The master craftsman
knows her tools backwards, and can choose the right tool for the job, and
when the choice of tool really doesn't matter and you can use whatever
happens to be the closest to hand.




-- 
Steven

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


Re: [Python-ideas] Boolean parameters guidelines

2016-05-08 Thread Steven D'Aprano
Not sure why this has migrated to this list instead of Python-Ideas.

Possibly a copy-paste error? *wink*

On Mon, 9 May 2016 12:24 am, Ian Kelly wrote:

> On May 8, 2016 12:42 AM, "Steven D'Aprano"  wrote:
>>
>> def pvariance(data, mu=None):
>> if iter(data) is data:
>> data = list(data)
>> n = len(data)
>> if n < 1:
>> raise StatisticsError('pvariance requires at least one data
> point')
>> ss = _ss(data, mu)
>> T, ss = _ss(data, mu)
> 
> Copy-paste error?

I have literally no idea how that happened.

Anyway, it's fixed now.


-- 
Steven

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


Help for a complex RE

2016-05-08 Thread Sergio Spina
In the following ipython session:

> Python 3.5.1+ (default, Feb 24 2016, 11:28:57) 
> Type "copyright", "credits" or "license" for more information.
>
> IPython 2.3.0 -- An enhanced Interactive Python.
>
> In [1]: import re
>
> In [2]: patt = r"""  # the match pattern is:
> ...: .+  # one or more characters
> ...: [ ] # followed by a space
> ...: (?=[@#D]:)  # that is followed by one of the
> ...: # chars "@#D" and a colon ":"
> ...:"""
> 
> In [3]: pattern = re.compile(patt, re.VERBOSE)
> 
> In [4]: m = pattern.match("Jun@i Bun#i @:Janji")
> 
> In [5]: m.group()
> Out[5]: 'Jun@i Bun#i '
> 
> In [6]: m = pattern.match("Jun@i Bun#i @:Janji D:Banji")
> 
> In [7]: m.group()
> Out[7]: 'Jun@i Bun#i @:Janji '
> 
> In [8]: m = pattern.match("Jun@i Bun#i @:Janji D:Banji #:Junji")
> 
> In [9]: m.group()
> Out[9]: 'Jun@i Bun#i @:Janji D:Banji '

Why the regex engine stops the search at last piece of string?
Why not at the first match of the group "@:"?
What can it be a regex pattern with the following result?

> In [1]: m = pattern.match("Jun@i Bun#i @:Janji D:Banji #:Junji")
> 
> In [2]: m.group()
> Out[2]: 'Jun@i Bun#i '



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


Re: pylint woes

2016-05-08 Thread Chris Angelico
On Mon, May 9, 2016 at 1:06 AM, DFS  wrote:
> On 5/8/2016 10:36 AM, Chris Angelico wrote:
>>
>> On Mon, May 9, 2016 at 12:25 AM, DFS  wrote:
>>>
>>> for category,name,street,city,state,zipcode in ziplists:
>>>   try: db.execute(cSQL, vals)
>>>   except (pyodbc.Error) as programError:
>>>if str(programError).find("UNIQUE constraint failed") > 0:
>>> dupeRow = True
>>> dupes +=1
>>> print " * duplicate address found: "+name+", "+street
>>>else:
>>> pyodbcErr = True
>>> print "ODBC error: %s " % programError
>>> conn.commit()
>>> 
>>>
>>
>> ... and then you just commit???!?
>>
>> ChrisA
>
>
>
> That's what commit() does.

Yes. Even if you got an error part way through, you just blithely commit. What?!

And yes, I am flat-out boggling at this.

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


Re: pylint woes

2016-05-08 Thread Stephen Hansen
On Sun, May 8, 2016, at 08:06 AM, DFS wrote:
> On 5/8/2016 10:36 AM, Chris Angelico wrote:
> > ... and then you just commit???!?
> >
> 
> That's what commit() does.
> 

I assure you, he knows what commit does :)

The point is, you don't usually commit after an error happens. You
rollback. Or correct the data. Since the data didn't go in, there should
(in theory) be nothing TO commit if an error happens. Or, there should
be partial data in that needs a rollback before you decide to do
something else.

-- 
Stephen Hansen
  m e @ i x o k a i . i o
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pylint woes

2016-05-08 Thread Stephen Hansen
On Sun, May 8, 2016, at 07:25 AM, DFS wrote:
> for nm,street,city,state,zipcd in zip(nms,street,city,state,zipcd):

> > for vals in zip(nms,street,city,state,zipcd):
> > nm,street,city,state,zipcd = vals
> > cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)"
> 
> 
> I like the first one better.  python is awesome, but too many options 
> for doing the same thing also makes it difficult.  For me, anyway.

Eeh, Now you're just making trouble for yourself.

for name, street, city, state, zipcd in zip(names, streets, cities,
states, zipcds):


may be sorta vaguely long, but its not that long. Just do it and move
on. Get over whatever makes you not like it. 


-- 
Stephen Hansen
  m e @ i x o k a i . i o
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Rustom Mody
On Sunday, May 8, 2016 at 5:38:18 PM UTC+5:30, Steven D'Aprano wrote:
> On Sun, 8 May 2016 01:57 am, Marko Rauhamaa wrote:
> 
> > A functional, enlightened, prosperous democracy is a very recent
> > historical anomaly. You don't want to jeopardize it naïvely.
> 
> Perhaps by implementing per-country limits on immigration?
> 
> *wink*

See:   
https://www.washingtonpost.com/news/rampage/wp/2016/05/07/ivy-league-economist-interrogated-for-doing-math-on-american-airlines-flight/

Closing line: "In America today, the only thing more terrifying than foreigners 
is...math."


Wonder how close to terrorists pythonists are
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pylint woes

2016-05-08 Thread DFS

On 5/8/2016 10:36 AM, Chris Angelico wrote:

On Mon, May 9, 2016 at 12:25 AM, DFS  wrote:

for category,name,street,city,state,zipcode in ziplists:
  try: db.execute(cSQL, vals)
  except (pyodbc.Error) as programError:
   if str(programError).find("UNIQUE constraint failed") > 0:
dupeRow = True
dupes +=1
print " * duplicate address found: "+name+", "+street
   else:
pyodbcErr = True
print "ODBC error: %s " % programError
conn.commit()




... and then you just commit???!?

ChrisA



That's what commit() does.




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


Re: pylint woes

2016-05-08 Thread Chris Angelico
On Mon, May 9, 2016 at 12:25 AM, DFS  wrote:
> for category,name,street,city,state,zipcode in ziplists:
>   try: db.execute(cSQL, vals)
>   except (pyodbc.Error) as programError:
>if str(programError).find("UNIQUE constraint failed") > 0:
> dupeRow = True
> dupes +=1
> print " * duplicate address found: "+name+", "+street
>else:
> pyodbcErr = True
> print "ODBC error: %s " % programError
> conn.commit()
> 
>

... and then you just commit???!?

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


Re: pylint woes

2016-05-08 Thread DFS

On 5/7/2016 11:46 PM, Stephen Hansen wrote:

On Sat, May 7, 2016, at 08:04 PM, DFS wrote:

The lists I actually use are:

for j in range(len(nms)):
  cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)"
  vals = nms[j],street[j],city[j],state[j],zipcd[j]


The enumerated version would be:

ziplists = zip(nms,street,city,state,zipcd)
for nm,street,city,state,zipcd in ziplists:
  cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)"
  vals = nm,street,city,state,zipcd


I guess the enumeration() is a little nicer to look at.  Why do you
think it's more maintainable?


Code is read more then its written.

That which is nicer to look at, therefore, is easier to read.

That which is easier to read is easier to maintain.

Beyond that, its simpler, and more clearly articulates in the local
space what's going on.



That last one sounds like an art critic trying to exlain why Jackson 
Pollock's work doesn't suck.





Aside: I haven't tried, but is 'names' a bad idea or illegal for the
name of a python list or variable?


Nothing wrong with names. Or 'name', for that matter. Try to avoid
abbreviations.


np





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


Re: pylint woes

2016-05-08 Thread DFS

On 5/8/2016 1:50 AM, Jussi Piitulainen wrote:

DFS writes:


The lists I actually use are:

for j in range(len(nms)):
 cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)"
 vals = nms[j],street[j],city[j],state[j],zipcd[j]


The enumerated version would be:

ziplists = zip(nms,street,city,state,zipcd)
for nm,street,city,state,zipcd in ziplists:
 cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)"
 vals = nm,street,city,state,zipcd


I guess the enumeration() is a little nicer to look at.  Why do you
think it's more maintainable?


The following variations avoid the naming of the result of zip at all,
and also save a line or two, depending on what you actually do in the
loop, without introducing overly long lines. Judge for yourself.



I tried:

for nm,street,city,state,zipcd in zip(nms,street,city,state,zipcd):

but felt it was too long and wordy.




You don't need to name the individual components, if you only actually
use vals:

for vals in zip(nms,street,city,state,zipcd):
cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)"


I like that one.  But I do one more thing (get a category ID) than just 
use the vals.



ziplists = zip(categories,names,streets,cities,states,zipcodes)
for category,name,street,city,state,zipcode in ziplists:
  dupeRow, pyodbcErr = False, False
  catID = getDataID("catID","CATEGORIES","catDesc",category)
  cSQL  = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?,?,?,?,?)"
  vals  = 
datasrcID,searchID,catID,name,street,city,state,zipcode,str(loaddt)

  try: db.execute(cSQL, vals)
  except (pyodbc.Error) as programError:
   if str(programError).find("UNIQUE constraint failed") > 0:
dupeRow = True
dupes +=1
print " * duplicate address found: "+name+", "+street
   else:
pyodbcErr = True
print "ODBC error: %s " % programError
  addrReturned += 1
  if not dupeRow and not pyodbcErr:
   addrSaved += 1
  if addrWant != "all":
   if addrSaved >= addrWant: break
conn.commit()


That's the 'post to db' routine



Or you can opt to name the tuple and its components the other way
around:

for vals in zip(nms,street,city,state,zipcd):
nm,street,city,state,zipcd = vals
cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)"



I like the first one better.  python is awesome, but too many options 
for doing the same thing also makes it difficult.  For me, anyway.


Thanks


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


Re: [Python-ideas] Boolean parameters guidelines

2016-05-08 Thread Ian Kelly
On May 8, 2016 12:42 AM, "Steven D'Aprano"  wrote:
>
> def pvariance(data, mu=None):
> if iter(data) is data:
> data = list(data)
> n = len(data)
> if n < 1:
> raise StatisticsError('pvariance requires at least one data
point')
> ss = _ss(data, mu)
> T, ss = _ss(data, mu)

Copy-paste error?

> return _convert(ss/n, T)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pylint woes

2016-05-08 Thread Peter Otten
DFS wrote:

> On 5/7/2016 2:52 PM, Christopher Reimer wrote:
>> On 5/7/2016 9:51 AM, DFS wrote:
>>> Has anyone ever in history gotten 10/10 from pylint for a non-trivial
>>> program?
>>
>> I routinely get 10/10 for my code. While pylint isn't perfect and
>> idiosyncratic at times, it's a useful tool to help break bad programming
>> habits. Since I came from a Java background, I had to unlearn everything
>> from Java before I could write Pythonic code. It might help to use an
>> IDE that offers PEP8-compliant code suggestions (I use PyCharm IDE).
>>
>>> That's about as good as it's gonna get!
>>
>> You can do better.
> 
> 10/10 on pylint isn't better.  

Not always, but where you and pylint disagree I'm more likely to side with 
the tool ;)

> It's being robotic and conforming to the
> opinions of the author of that app.

The problem are the tool's limitations, the "being robotic" rather than 
following someone else's opinions.
 
> In fact, I think:
> 
> import os, sys, time, socket
> 
> is much more readable than, and preferable to,
> 
> import os
> import sys
> import time
> import socket
> 
> but pylint complains about the former.

Do you use version control?

>> You should strive for 10/10 whenever possible,
> 
> nah
> 
> 
>> figure out why you fall short and ask for help on the parts that don't
>> make sense.
> 
> I actually agree with ~3/4 of the suggestions it makes.  My code ran
> fine before pylint tore it a new one, and it doesn't appear to run any
> better after making various fixes.

Do you write unit tests?


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


Re: pylint woes

2016-05-08 Thread Peter Otten
Chris Angelico wrote:

> On Sun, May 8, 2016 at 1:28 PM, DFS  wrote:
>> Invalid constant name "cityzip" (invalid-name)
>> Invalid constant name "state" (invalid-name)
>> Invalid constant name "miles" (invalid-name)
>> Invalid constant name "store" (invalid-name)
>> Invalid variable name "rs" (invalid-name)
> 
> ... huh?? The first four seem to have been incorrectly detected as
> constants. How are they used?

As globals. pylint doesn't like it when you put your normal code outside a 
function, and I agree with the general idea. The problem is that it's not 
smart enough to recognize the exceptions like

plus_one = make_adder(1)

where plus_one obeys the naming convention for a function, but the linter 
asks you to change the line to

PLUS_ONE = make_adder(1)

In

Row = collections.namedtuple("Row", "alpha beta")

though pylint does recognize that collections.namedtuple() produces a class,
so there might also be a way to teach it how to handle the custom factory.

The OP should of course put the whole shebang into a main() function. That 
also simplifies it to determine which values should be passed as arguments 
when he breaks his blob into smaller parts.

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


Re: pylint woes

2016-05-08 Thread Chris Angelico
On Sun, May 8, 2016 at 10:50 PM, D'Arcy J.M. Cain
 wrote:
> On Sun, 8 May 2016 14:21:49 +1000
> Chris Angelico  wrote:
>> if verbose:
>> verbiage = print
>> else:
>> def verbiage(*args): pass
>
> I have never understood why the def couldn't start on the same line as
> the else:
>
> if verbose: verbiage = print
> else: def verbiage(*args): pass
>
> The colon effectively starts a block so why not allow it?

Having two colons makes it a bit messy, so I can fully accept that
this *shouldn't* be done. Whether or not it's reasonable that it
*can't* be done is a question for the parser; but even if the parser
permitted it, I would expect style guides to advise against it.

> By the way, I think you meant "def verbiage(*args, **kws): pass"

In the general case, yes. But in this specific case, I actually prefer
not to accept keyword args in a null function; maybe permit sep=" "
and end="\n", but if someone sets file or flush, it's probably a
mistake (you most likely don't want verbiage("message", file=logfile)
to silently not do it). YMMV; maybe you want that, so yeah, toss in
the kwargs absorber.

>> Then, instead of "if verbose: print(var)", you would use
>> "verbiage(var)". Of course, you want something better than "verbiage"
>> as your name; the nature of your verbose output might give a clue as
>> to what name would work.
>
> How about "print"?
>
> if not verbose:
> def print(*args, **kws): pass

The danger of that is that it's too general. I like to recommend a
little thing called "IIDPIO debugging" - If In Doubt, Print It Out.
That means: If you have no idea what a piece of code is doing, slap in
a print() call somewhere. It'll tell you that (a) the code is actually
being executed, and (b) whatever info you put between the parens
(ideally, some key variable or parameter). Part A is often the
important bit :) The trouble with a verbose flag controlling all
print() calls is that IIDPIO debugging suddenly doesn't work; plus,
it's easy to copy and paste code to some other module and not notice
that you don't have a verbosity check at the top, and then wonder why
disabling verbose doesn't fully work. Both problems are solved by
having a dedicated spam function, which will simply error out if you
didn't set it up properly.

But again, if you know what you're doing, go for it! This is exactly
why print became a function in Py3 - so that you *can* override it.

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


Re: pylint woes

2016-05-08 Thread D'Arcy J.M. Cain
On Sun, 8 May 2016 14:21:49 +1000
Chris Angelico  wrote:
> if verbose:
> verbiage = print
> else:
> def verbiage(*args): pass

I have never understood why the def couldn't start on the same line as
the else:
 
if verbose: verbiage = print
else: def verbiage(*args): pass
 
The colon effectively starts a block so why not allow it?
 
By the way, I think you meant "def verbiage(*args, **kws): pass"

> Then, instead of "if verbose: print(var)", you would use
> "verbiage(var)". Of course, you want something better than "verbiage"
> as your name; the nature of your verbose output might give a clue as
> to what name would work.

How about "print"?

if not verbose:
def print(*args, **kws): pass

-- 
D'Arcy J.M. Cain
Vybe Networks Inc.
http://www.VybeNetworks.com/
IM:da...@vex.net VoIP: sip:da...@vybenetworks.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Steven D'Aprano
On Sun, 8 May 2016 01:57 am, Marko Rauhamaa wrote:

> A functional, enlightened, prosperous democracy is a very recent
> historical anomaly. You don't want to jeopardize it naïvely.

Perhaps by implementing per-country limits on immigration?

*wink*


-- 
Steven

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


Re: Pylint prefers list comprehension over filter...

2016-05-08 Thread Steven D'Aprano
On Sun, 8 May 2016 08:01 am, Christopher Reimer wrote:

> On 5/7/2016 2:22 PM, Chris Angelico wrote:

>> Also, be sure you read this part of PEP 8:
>>
>>
https://www.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds
> Recruiters and hiring managers *are* hobgoblins with with little minds.
> And definitely not PEP8-complaint. :)

Do you think that recruiters and hiring managers read your code at all, let
alone that they read it will an eye to PEP 8 compliance?

No recruiter[1] will do this. No recruiter will even know what PEP 8 is.
They're looking for technical buzzwords ("ten years experience with
Django"), they aren't qualified to judge whether your Django code is good,
bad or indifferent. That's up to the client.

A hiring manager with a technical background might, once you are in
consideration for the job. More likely they will delegate any judgement to
a technical manager, or programmer, who may or may not be a hobgoblin with
a little mind. There are plenty of programmers who are obsessive about
following PEP 8 even when it makes the code worse:

mywidget.component['key'] = (mywidget.grippley.count_item(spam or eggs)
 + 1)


(I've met plenty of technical people who are opinionated and badly informed,
not just managers. Just last week, I was told by one programmer that
Mersenne Twister, the default RNG used by Python, is well-known to be
biased, and that "everybody knows" not to use it to choose an item from a
list because it is documented "everywhere" as being more likely to choose
the first or the last item than any of the others.)







[1] Sweeping generalisation. In a world of 7 billion people, there's
probably one or two exceptions somewhere.



-- 
Steven

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


Re: pylint woes

2016-05-08 Thread Steven D'Aprano
On Sun, 8 May 2016 11:16 am, DFS wrote:

> address data is scraped from a website:
> 
> names = tree.xpath()
> addr  = tree.xpath()

Why are you scraping the data twice?

names = addr = tree.xpath()

or if you prefer the old-fashioned:

names = tree.xpath()
addr = names

but that raises the question, how can you describe the same set of data as
both "names" and "addr[esses]" and have them both be accurate?


> I want to store the data atomically, 

I'm not really sure what you mean by "atomically" here. I know what *I* mean
by "atomically", which is to describe an operation which either succeeds
entirely or fails. But I don't know what you mean by it.



> so I parse street, city, state, and 
> zip into their own lists.

None of which is atomic.

> "1250 Peachtree Rd, Atlanta, GA 30303
> 
> street = [s.split(',')[0] for s in addr]
> city   = [c.split(',')[1].strip() for c in addr]
> state  = [s[-8:][:2] for s in addr]
> zipcd  = [z[-5:] for z in addr]

At this point, instead of iterating over the same list four times, doing the
same thing over and over again, you should do things the old-fashioned way:

streets, cities, states, zipcodes = [], [], [], []
for word in addr:
items = word.split(',')
streets.append(items[0])
cities.append(items[1].strip())
states.append(word[-8:-2])
zipcodes.append(word[-5:])


Oh, and use better names. "street" is a single street, not a list of
streets, note plural.



-- 
Steven

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


Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread beliavsky--- via Python-list
On Saturday, May 7, 2016 at 4:02:32 AM UTC-4, Stephen Hansen wrote:
> On Fri, May 6, 2016, at 11:43 PM, Gregory Ewing wrote:
> > Steven D'Aprano wrote:
> > > Who is setting and enforcing this quota, and given that only about 1 in 20
> > > Python programmers is a woman, do you think men are seriously missing out
> > > on any opportunities?
> > 
> > Suppose there are 100 people wanting to ask questions, and
> > there is only time to answer 10 questions. If the 1 in 20
> > ratio holds, then 5 of those people are women and the other
> > 95 are men.
> > 
> > Alternating between men and women means that all of the
> > women get their questions answered, and only 5/95 of the
> > men. So in this example, if you're a woman you have a 100%
> > chance of getting answered, and if you're a man you only
> > have a 5.26% chance.
> > 
> > Whether you think this is a good strategy or not,
> > beliavsky is right that it's not "equal".
> 
> This is a pedantically and nonsensical definition of "equal", that
> ignores the many, many reasons why there are 1 in 20 women in that
> conference. Its looking at the end effect and ignoring everything that
> leads up to it, and deciding its instead special rights -- this is the
> great argument against minorities getting a voice, that their requests
> for equal *opportunity* are instead *special rights* that diminish the
> established majority's entrenched power. 
> 
> Those women are dealing with suppression, discrimination and dismissal
> on multiple levels that leave them in a disenfranchised position. 

The sex disparity in Python and in tech in general could be due in part to 
discrimination, but it could also be due to different male and female interests 
and (gasp) aptitudes on average. Are Asian-Americans over-represented in tech 
because whites have been suppressed? There are far more female than male 
teachers. I don't attribute it to anti-male suppression but to greater female 
interest in working with children.

In our public middle school (grades 6-8, ages 11-13) there is a programming 
club that is open to girls. My son is shut out because of his sex. That is just 
as wrong as excluding him because of his skin color. I oppose such 
discrimination.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python PygLatin

2016-05-08 Thread Cai Gengyang
I just "clicked" through the lesson on Conditionals and Control Flows and am on 
the lesson "PygLatin" .

This will hopefully be a more interesting and interactive lesson because I will 
be building a PygLatin Translator ...

It seems to me like it will take a long time before I can reach the point where 
I can become a master of programming languages and even create new programming 
languages and technologies. This is a long road ahead, but I believe it is 
worth it because the power of a new technology does eventually translate into 
money. If one looks at the Forbes List, you will see that there are 4 
programmers amongst the top ten richest people in the world (Bill Gates, Mark 
Zuckerberg, Larry Ellison and Jeff Bezos) , a very large percentage. Science 
and Technology is in a sense the most egalitarian field in the world, because 
it involves using your brains and creativity. You don't need to have a father 
who is a director at Goldman Sachs or a mother who is the admissions officer at 
Harvard to succeed in this line. All you need is have the ability to create 
something that many users love to use.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Steven D'Aprano
On Sunday 08 May 2016 13:40, Random832 wrote:

> On Sat, May 7, 2016, at 22:43, Steven D'Aprano wrote:
>> > If not for the quotas, a citizen of some other country would have an
>> > equal chance to get a green card as a citizen of India or China.
>> 
>> If you have a big hat with 5,000,000 tickets marked "Indian", and 500
>> tickets marked "Finish", and you stick your hand in the hat and rummage
>> around and pick a random ticket, do you really think that you have an
>> equal
>> chance of selecting an Indian ticket and a Finish ticket?
> 
> But that's not what it is. You would have, say, 1,000 tickets labeled
> "green card" and 100,000 tickets labeled "no green card", and  (say)
> 12,000 Indian people and 50 Finnish people each get their turn drawing
> from that same bucket. In your version, the Finnish people draw from a
> bucket with 500 green card tickets and no "no green card" cards, and the
> Indian people draw from a bucket with 500 green card tickets and 11,500
> "no green card" tickets.


That's not how the green card works.

The US immigration system is pretty messed up in many ways, being the overly 
complex and confusing product of many competing and contradictory 
requirements[1], but there's nothing even vaguely analogous to being 
randomly denied entry by pure chance. There's no such thing as "No Green 
Card" tickets that you can draw -- in principle at least, if you are refused 
entry, it is because you do not meet the requirements for a visa. (E.g. you 
have AIDS, are a known trafficker or smuggler, a member of the Communist 
Party in certain countries, have lied to the immigration officer, have 
publicly called for the violent overthrow of the US government, or are 
unable to provide sufficient evidence that you will go back home when your 
visa expires.)

Aside: immigration officials have great power in deciding who meets the 
requirement for a visa, and the US government and courts are unable to over-
rule them except in a matter of the interpretation of the law. With one 
exception: the rules for banning terrorists can be over-ruled by the 
Attorney-General and the Secretary of State. In other words, of all the 
things which a person might do to render themselves ineligible for a visa 
into the USA, there is no higher power able to over-ride the immigration 
official, *except* that if you fail the "No Terrorists Allowed" rule, the A-
G and Sec of State, acting together, can choose to grant you an exemption.

Go figure.

(The intent, I presume, is that if somebody like General Pinochet of Chile 
is found guilty of crimes against humanity by the European courts, which 
would count as terrorism, the US could still grant him a visa.)



[1] Some businesses want easy immigration, so they can drive down the cost 
of skilled or unskilled labour; some people want to prohibit work visas, to 
keep wages high; some want to allow people of diverse nationalities into the 
melting pot, while others want to keep the national character as it is 
without being overrun by large numbers of foreigners with strange or 
terrible customs and practices like sati, female genital mutilation[2], or 
effective social safety nets.


[2] Apparently *male* genital mutilation is perfectly acceptable.


-- 
Steve

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


SQLObject 2.2

2016-05-08 Thread Oleg Broytman
Hello!

I'm pleased to announce version 2.2.0, the first stable release of branch
2.2 of SQLObject.


What's new in SQLObject
===

Features & Interface


* Add function col.use_microseconds(True/False). Default is to use
  microseconds (True).

* For MSSQL use datetime2(6) and time(6) columns.

* Columns for ForeignKey are created using idType of the referenced
  table.

Minor features
--

* Add sqlbuilder.CONCAT to generate concatenation command (either using
  function CONCAT() or '||' operator).

* Minor refactoring to pave the way to Python 3.

* Document MSSQL server versions.

Bugfixes


* Fix a bug: mxDateTime doesn't support microseconds; %s in mxDateTime
  format means ticks.

Tests
-

* Speedup SQLite connections in tests.

* Added new test help setupCyclicClasses to setup classes with mutual
  references.

Contributors for this release are Andrew Ziem and Nathan Edwards.

For a more complete list, please see the news:
http://sqlobject.org/News.html


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).

Python 2.6 or 2.7 is required.


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
https://pypi.python.org/pypi/SQLObject/2.2.0

News and changes:
http://sqlobject.org/News.html

Oleg.
-- 
 Oleg Broytmanhttp://phdru.name/p...@phdru.name
   Programmers don't die, they just GOSUB without RETURN.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Marko Rauhamaa
Random832 :
> But that's not what it is. You would have, say, 1,000 tickets labeled
> "green card" and 100,000 tickets labeled "no green card", and (say)
> 12,000 Indian people and 50 Finnish people each get their turn drawing
> from that same bucket. In your version, the Finnish people draw from a
> bucket with 500 green card tickets and no "no green card" cards, and
> the Indian people draw from a bucket with 500 green card tickets and
> 11,500 "no green card" tickets.

Or:

   In its majestic equality, the law forbids rich and poor alike to
   sleep under bridges, beg in the streets and steal loaves of bread.

   https://en.wikiquote.org/wiki/Anatole_France>


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


Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Marko Rauhamaa
Chris Angelico :

> So the question is: Do we care about country equality or individual
> equality? You can't have both.

That's why there's been a long-standing initiative to split California
into multiple states:

  https://en.wikipedia.org/wiki/Six_Californias>

Each state gets two senate seats, and California, being the most
populous state, suffers.

The biggest analogous outrage in the world, though, is that of the
International Football Association Board (IFAB), where the [English]
Football Association, the Scottish Football Association, the Football
Association of Wales and the [Northern] Irish Football Association each
have a vote while the ROW (aka FIFA) has four votes.


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