Re: Code review

2014-11-05 Thread Jean-Michel Pichavant
- Original Message -
> From: "C Smith" 
> I read that with 2.7 that I had to initialize class variables to
> immutable types. I think because I was working with the lists before
> they had been altered and were still empty lists. I will mess around
> tomorrow with the classes you suggested as I have yet to make use of
> decorators. Thanks.

The problem you referring too is probably the default value in *function 
definition*.

Never write

class Foo(object):
  def __init__(self, bar=[]):
self.bar = bar

The empty list is evaluated at the function definition and will be shared by 
all instances of the class.

What you can do is

class Foo(object):
  def __init__(self, bar=None): # None is immutable
self.bar = bar or []

On a completely unrelated topic:
I think you are using too much of default values for you arguments.
I tend to use them only for keeping something backward compatible.

Otherwise, use positional arguments, remember that explicit is better than 
implicit.

Rememer your Table class:
class Table(object):
  def __init__(self,bigblind=20,PLAYERNUM=0,pot=0,PLAYERORDER=None, 
hand_done=0, 
left_to_act=None,cost_to_play=0,in_hand=None,last_raise=0,cards_in_play=None,round='preflop'):

You do not need to to pass all attribute initializers to your init method. For 
instance PLAYERNUM, which should be lowercase by the way, is clearly not 
intended to be set at the Table creation, it is something changed when filling 
seats.

Actually, since you've created your table this way:

table1=Table(bingblind=1)

It probably means that your table __init__ method should look like:

def __init__(self, bigblind):
  self.bigblind= bigblind
  self.hand_one = False
  self.left_to_act = []
  # etc...

By the way, avoid using directly 1 and 0 for coding booleans, use True and 
False (see hand_one attribute).

JM


-- IMPORTANT NOTICE: 

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


Re: pkcs7 signing

2014-11-05 Thread Robin Becker

On 05/11/2014 06:40, dieter wrote:

Robin Becker  writes:


Is there a way to do pkcs7 / 12 signing with python.


Have you checked whether "OpenSSL" supports this kind of signing?
If it does, then you likely can use this via several Python wrappings
for "OpenSSL".

I checked that the openssl library does have a call for this, however, I cannot 
see this exposed in either the cryptography or py2crypto packages. The code may 
be in there, but I don't see it obviously exposed. I think m2crypto might do the 
job, but building it for windows is a pain and I probably have to build it 6 
times ie 32 & 64 bits x 2.7 3.3 & 3.4. There are pre-built versions of openssl, 
but that's also a moving target right now.

--
Robin Becker

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


Re: Regex substitution trouble

2014-11-05 Thread Eugene
massi_...@msn.com wrote:

> Hi everyone,
> 
> I'm not really sure if this is the right place to ask about regular
> expressions, but since I'm usin python I thought I could give a try 
:-)
> Here is the problem, I'm trying to write a regex in order to 
substitute
> all the occurences in the form $"somechars" with another string. This 
is
> what I wrote:
> 
> newstring = re.sub(ur"""(?u)(\$\"[\s\w]+\")""", subst, oldstring)
> 
> This works pretty well, but it has a problem, I would need it also to
> handle the case in which the internal string contains the double 
quotes,
> but only if preceeded by a backslash, that is something like
> $"somechars_with\\"doublequotes". Can anyone help me to correct it?
> 
> Thanks in advance!
Hi!

Next snippet works for me:

re.sub(r'\$"([\s\w]+(\\")*[\s\w]+)+"', 'noop', r'$"te\"sts\"tri\"ng"')

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


Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Ivan Evstegneev
Hello everyone,

 

I'm a Python beginner and just getting familiar with it. (I need it for my
EE B.Sc. project) 

For the learning purposes I use IDLE and (Learning Python by written by Mark
Lutz).

Let's say that I have some earlier experience with C language, but still
Python is a different one )))

 

Anyway, the question I would like to ask is about understanding "help"
contents.

It may look to obvious and even a dumb question, but still I need your help.

 

Here is a brief background with example in order to introduce my problem in
more clear way:

 

Suppose I get some list created: 

 

>>>L=[i for i in range(1,15,2)]

As it can be seen, this is the odd numbers list: [1, 3, 5, 7, 9, 11, 13]

 

Supppose I need to check the occurrence of number 7, in this case I'll just
write:

>>>L.index(7)

The result is :3

 

So here is the question itself:

If I use the help command to check the "range" command I get this info: 

 

range(stop) -> range object

range(start, stop[, step]) -> range object

 

As you've seen in my example I used range(1,15,2). But this knowledge I got
from googling a couple of sites.

I still can't understand the "help" command description. 

For instance, how do I need to understand that (start,stop[,step])  it's
just a three numbers? 

What do those brackets--> [,] mean?

 

The same about "str.replace" command, where I get this:

 

S.replace(old, new[, count]) - using this description I can't really
understand how to write the "replace" function parameters.

 

So I googled it up and found this example in order to get more clear
understanding of command use.

 

str = "this is string examplewow!!! this is really string"

print str.replace("is", "was")

print str.replace("is", "was", 3)

 

The result: 

thwas was string examplewow!!! thwas was really string

thwas was string examplewow!!! thwas is really string

 

But still how do I know that those "old, new" are the strings and [,count]
just a number? 

 I mean, it was more naturally(as a baginner) to me to write
str.replace(is,was[,3]) and that's all. 

 

 

Finally, as for my opinion, this is a lame way to learn  "what a command do"
by constantly googling it for examples. 

 

I need to get more familiar with "help", but the main problem, is that I
couldn't find any suitable explanations/tutorials about "help" syntax and
etc. (maybe didn't search well).

 

Any explanations/links will be greatly appreciated. I need some help for
"help" ^_^

 

Thanks in advance,

 

Ivan.   

 

 

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


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Jean-Michel Pichavant
 Original Message -
> From: "Ivan Evstegneev" 
> To: python-list@python.org
> Sent: Wednesday, 5 November, 2014 12:00:16 PM
> Subject: Understanding "help" command description syntax - explanation needed
> So here is the question itself:
> 
> If I use the help command to check the “range” command I get this
> info:
> 
> 
> 
> range(stop) -> range object
> 
> range(start, stop[, step]) -> range object

With python 2.7, when I type help(range), I get

"""
Help on built-in function range in module __builtin__:

range(...)
range([start,] stop[, step]) -> list of integers

Return a list containing an arithmetic progression of integers.
range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.
When step is given, it specifies the increment (or decrement).
For example, range(4) returns [0, 1, 2, 3].  The end point is omitted!
These are exactly the valid indices for a list of 4 elements.
"""

range([start,] stop[, step]) tells you how to call the range function, there's 
a start, stop and step argument.
The purpose of these arguments are given by the longer description.

brackets [] means that the argument is optional.

Though there's nothing wrong with googling the function for help, I'm doing it 
all the time.
Actually, the python documentation is a better place to get help on a 
particular function, just make sure you hit the correct version, for either 
python 2 or 3:

https://docs.python.org/2/library/functions.html#range

I'm using python's help function only when working offline.

JM



-- IMPORTANT NOTICE: 

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


I need algorithm for my task

2014-11-05 Thread lordvital21
I have line 'pythonpythonpyth'. How do I know which word is the foundation 
line?.
Other examples:
"pythonpythonpyth" is python
"DOLORIUMD" is DOLORIUM
"HELLOLHELLO" is HELLOL
"thewordword" is thewordword

I need to know whether the word in the text is repeated and get it. This will 
be the key.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Mark Lawrence

On 05/11/2014 11:55, Jean-Michel Pichavant wrote:

 Original Message -

From: "Ivan Evstegneev" 
To: python-list@python.org
Sent: Wednesday, 5 November, 2014 12:00:16 PM
Subject: Understanding "help" command description syntax - explanation needed
So here is the question itself:

If I use the help command to check the “range” command I get this
info:



range(stop) -> range object

range(start, stop[, step]) -> range object


With python 2.7, when I type help(range), I get

"""
Help on built-in function range in module __builtin__:

range(...)
 range([start,] stop[, step]) -> list of integers

 Return a list containing an arithmetic progression of integers.
 range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.
 When step is given, it specifies the increment (or decrement).
 For example, range(4) returns [0, 1, 2, 3].  The end point is omitted!
 These are exactly the valid indices for a list of 4 elements.
"""

range([start,] stop[, step]) tells you how to call the range function, there's 
a start, stop and step argument.
The purpose of these arguments are given by the longer description.

brackets [] means that the argument is optional.

Though there's nothing wrong with googling the function for help, I'm doing it 
all the time.
Actually, the python documentation is a better place to get help on a 
particular function, just make sure you hit the correct version, for either 
python 2 or 3:

https://docs.python.org/2/library/functions.html#range

I'm using python's help function only when working offline.

JM



There is an issue on the bug tracker about the difference between help 
for range between Python 2 and 3, see http://bugs.python.org/issue22785


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


RE: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Ivan Evstegneev
Firtst of all thanks for reply.

>>brackets [] means that the argument is optional.

That's what I'm talking about (asking actually), where do you know it from? 
I mean, if there are some resources, which explain all these syntax 
abbreviations? The general concept.


Like this one(just for example):
class bytearray([source[, encoding[, errors]]]) --- What does it mean? 
Is that  I can use it in optional way? 
Like: class bytearray(source) or class bytearray(encoding) ?
or just write down all three of them? 
In which format do I do so? 

Sincerely,

Ivan.

 




-Original Message-
From: Jean-Michel Pichavant [mailto:jeanmic...@sequans.com] 
Sent: Wednesday, November 5, 2014 13:55
To: Ivan Evstegneev
Cc: python-list@python.org
Subject: Re: Understanding "help" command description syntax - explanation 
needed

 Original Message -
> From: "Ivan Evstegneev" 
> To: python-list@python.org
> Sent: Wednesday, 5 November, 2014 12:00:16 PM
> Subject: Understanding "help" command description syntax - explanation 
> needed So here is the question itself:
> 
> If I use the help command to check the “range” command I get this
> info:
> 
> 
> 
> range(stop) -> range object
> 
> range(start, stop[, step]) -> range object

With python 2.7, when I type help(range), I get

"""
Help on built-in function range in module __builtin__:

range(...)
range([start,] stop[, step]) -> list of integers

Return a list containing an arithmetic progression of integers.
range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.
When step is given, it specifies the increment (or decrement).
For example, range(4) returns [0, 1, 2, 3].  The end point is omitted!
These are exactly the valid indices for a list of 4 elements.
"""

range([start,] stop[, step]) tells you how to call the range function, there's 
a start, stop and step argument.
The purpose of these arguments are given by the longer description.

brackets [] means that the argument is optional.

Though there's nothing wrong with googling the function for help, I'm doing it 
all the time.
Actually, the python documentation is a better place to get help on a 
particular function, just make sure you hit the correct version, for either 
python 2 or 3:

https://docs.python.org/2/library/functions.html#range

I'm using python's help function only when working offline.

JM



-- IMPORTANT NOTICE: 

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

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


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Chris Angelico
On Wed, Nov 5, 2014 at 10:00 PM, Ivan Evstegneev
 wrote:
> range(start, stop[, step]) -> range object
>
> For instance, how do I need to understand that (start,stop[,step])  it’s
> just a three numbers?
>
> What do those brackets--> [,] mean?

The docs for range() in Python 3 do need improvement, as Mark said,
although there's a bit more info than you see there. The exact text
varies from one version to another, but underneath that first line
should be something like:

"Return a virtual sequence of numbers from start to stop by step."

That should tell you a bit more, at least.

As to the brackets, they're a common convention meaning "optional".
This is much bigger than Python, so it's not actually explained
anywhere. (I've no idea where someone would go to try to find info on
these sorts of conventions. It's a little hard to do a Google search
for symbols and their usages. But that's what mailing lists like this
are for.) You can create a range object with two arguments (start and
stop) or three (start, stop, and step). When an argument is optional,
it usually has a default, and in this case, the default step is 1 -
every integer will be included.

Don't be afraid to ask questions. There are plenty of people here who
know both Python and C (I'm one of them), and we're happy to help out.
And hey, you might find you can contribute a better piece of help text
for something, and then we can make it better for every future
wonderer :)

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


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Larry Martell
On Wed, Nov 5, 2014 at 7:13 AM, Ivan Evstegneev  wrote:
> Firtst of all thanks for reply.
>
>>>brackets [] means that the argument is optional.
>
> That's what I'm talking about (asking actually), where do you know it from?

I know it because I've been a programmer for 39 years.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Chris Angelico
On Wed, Nov 5, 2014 at 11:13 PM, Ivan Evstegneev
 wrote:
> That's what I'm talking about (asking actually), where do you know it from?
> I mean, if there are some resources, which explain all these syntax 
> abbreviations? The general concept.
>
>
> Like this one(just for example):
> class bytearray([source[, encoding[, errors]]]) --- What does it mean?
> Is that  I can use it in optional way?
> Like: class bytearray(source) or class bytearray(encoding) ?
> or just write down all three of them?
> In which format do I do so?

With consecutive defaults, like that, it's written as a nested series.
You have three optional parts: the first is "source[, encoding[,
errors]]", the second (completely inside that) is ", encoding[,
errors]", and the third (also inside) is ", errors". The first one
gives you two options:

class bytearray()
class bytearray(source[, encoding[, errors]])

Then that gives you two more options:
class bytearray(source)
class bytearray(source, encoding[, errors])

Which itself gives two options:
class bytearray(source, encoding)
class bytearray(source, encoding, errors)

So what you actually have is four real, usable options:
class bytearray()
class bytearray(source)
class bytearray(source, encoding)
class bytearray(source, encoding, errors)

Does that make sense? You're allowed to provide no options, or
anywhere up to three, but they have to be the first N options.

In this particular case, it doesn't make sense to provide the later
options without also providing the earlier ones. The encoding and
errors parameters affect how source is interpreted, and errors affects
how the encoding copes with stuff it can't handle, so it wouldn't make
sense to provide either without source, or source and errors without
encoding. That's why it's written as a nested set of optional
sections, rather than as a series of stand-alone options.

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


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Chris Angelico
On Wed, Nov 5, 2014 at 11:13 PM, Ivan Evstegneev
 wrote:
> That's what I'm talking about (asking actually), where do you know it from?
> I mean, if there are some resources, which explain all these syntax 
> abbreviations? The general concept.

The best way to find clues about what the conventions mean is to find
something that codifies them in some way. Like this:

http://docopt.org/

That's talking about command-line arguments to an application, but a
lot of the notations are the same.

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


Re: I need algorithm for my task

2014-11-05 Thread Chris Angelico
On Wed, Nov 5, 2014 at 10:58 PM,   wrote:
> I have line 'pythonpythonpyth'. How do I know which word is the foundation 
> line?.
> Other examples:
> "pythonpythonpyth" is python
> "DOLORIUMD" is DOLORIUM
> "HELLOLHELLO" is HELLOL
> "thewordword" is thewordword
>
> I need to know whether the word in the text is repeated and get it. This will 
> be the key.

This sounds like it's probably homework, so I won't actually give you
the code, just a starting hint.

Python lets you slice a string to get back a substring. Start with a
really simple algorithm like "see if the first N letters are also the
next N letters and so on until you pass the end of the string", then
word that up into Python code. Later on, you can look into making it
less naive, but start simple and work up from there.

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


RE: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Ivan Evstegneev
Chris,

You got my point exactly. ^_^ This is not about a "range" command itself, but 
those conventions.
Thanks.

Larry,

>> That's what I'm talking about (asking actually), where do you know it from?

>>I know it because I've been a programmer for 39 years.

I didn't intend to offence anyone here. Just asked a questions ^_^



-Original Message-
From: Python-list 
[mailto:python-list-bounces+webmailgroups=gmail@python.org] On Behalf Of 
Chris Angelico
Sent: Wednesday, November 5, 2014 14:16
Cc: python-list@python.org
Subject: Re: Understanding "help" command description syntax - explanation 
needed

On Wed, Nov 5, 2014 at 10:00 PM, Ivan Evstegneev  
wrote:
> range(start, stop[, step]) -> range object
>
> For instance, how do I need to understand that (start,stop[,step])  
> it’s just a three numbers?
>
> What do those brackets--> [,] mean?

The docs for range() in Python 3 do need improvement, as Mark said, although 
there's a bit more info than you see there. The exact text varies from one 
version to another, but underneath that first line should be something like:

"Return a virtual sequence of numbers from start to stop by step."

That should tell you a bit more, at least.

As to the brackets, they're a common convention meaning "optional".
This is much bigger than Python, so it's not actually explained anywhere. (I've 
no idea where someone would go to try to find info on these sorts of 
conventions. It's a little hard to do a Google search for symbols and their 
usages. But that's what mailing lists like this are for.) You can create a 
range object with two arguments (start and
stop) or three (start, stop, and step). When an argument is optional, it 
usually has a default, and in this case, the default step is 1 - every integer 
will be included.

Don't be afraid to ask questions. There are plenty of people here who know both 
Python and C (I'm one of them), and we're happy to help out.
And hey, you might find you can contribute a better piece of help text for 
something, and then we can make it better for every future wonderer :)

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

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


Re: I need algorithm for my task

2014-11-05 Thread Peter Otten
lordvita...@gmail.com wrote:

> I have line 'pythonpythonpyth'. How do I know which word is the foundation
> line?. Other examples:
> "pythonpythonpyth" is python
> "DOLORIUMD" is DOLORIUM
> "HELLOLHELLO" is HELLOL
> "thewordword" is thewordword
> 
> I need to know whether the word in the text is repeated and get it. This
> will be the key.

A simple approach that might work (I didn't implement it to verify):

Look for other occurences of the first letter. If there are none you have 
the "foundation", if there are any, split the line before them and check if 
the rest of the line can be constructed as a (possibly truncated) repetition 
of the beginning. For

fifafofifaf

you'd have to check

fi fafofifaf --> false
fifa fofifaf --> false
fifafo fifaf --> true

so we don't care about

fifafofi faf
fifafofifa f


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


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Chris Angelico
On Wed, Nov 5, 2014 at 11:31 PM, Ivan Evstegneev
 wrote:
>>> That's what I'm talking about (asking actually), where do you know it from?
>
>>>I know it because I've been a programmer for 39 years.
>
> I didn't intend to offence anyone here. Just asked a questions ^_^

Don't worry about offending people. Even if you do annoy one or two,
there'll be plenty of us who know to be patient :) And I don't think
Larry was actually offended; it's just that some questions don't
really have easy answers - imagine someone asking a great
mathematician "But how do you KNOW that 2 + 2 is 4? Where's it written
down?"... all he can say is "It is".

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


Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread Grant Edwards
On 2014-11-05, Dennis Lee Bieber  wrote:

>  "machine code" typically implies an instruction set specific
> to that machine... ALL computers operate in BINARY logic (a bit only
> holds 0 or 1). How you get those bits into the computer is
> irrelevant.

Just to muddy the water...

_Most_ parts of most computers operate in binary.  Portions of some
parts (e.g. some NAND flash) use ternary, quaternary, or octal.  IIRC,
four-state transistor cells are pretty common at the moment, but some
vendor(s) are working with 8-state cells.

-- 
Grant Edwards   grant.b.edwardsYow! Hold the MAYO & pass
  at   the COSMIC AWARENESS ...
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I need algorithm for my task

2014-11-05 Thread Denis McMahon
On Wed, 05 Nov 2014 03:58:33 -0800, lordvital21 wrote:

> I have line 'pythonpythonpyth'. How do I know which word is the
> foundation line?.
> Other examples:
> "pythonpythonpyth" is python "DOLORIUMD" is DOLORIUM "HELLOLHELLO" is
> HELLOL "thewordword" is thewordword
> 
> I need to know whether the word in the text is repeated and get it. This
> will be the key.

Well, the way you describe it:

So first you want to check if the first letter is also the second letter
Then you want to check if the first 2 letters are also the 3rd and 4th
Then you want to check if the first 3 letters are also the 4th-6th
Then you want to check if the first 4 letters are also the 5th-8th

So generally you want to check if the first n letters are also the second 
n letters, increasing n by 1 at a time until you reach your terminating 
condition.

So what is your terminating condition? I can see two possibilities. You 
run out of letters in the second section, or you find a match.

Here are a few more hints to help get you started:

A string is a list of characters.
A list can be sliced.
You can measure the length of a list.
You can compare the lengths of two lists.
You can compare two lists.
You can get the length of a string.
The maximum length of a repeated word in a string can not be more than 
half the length of the string.

However, the examples you give do not match the way you describe it. The 
examples you give assume the first word ends when the letter that started 
it is found again.

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


Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread Chris Angelico
On Thu, Nov 6, 2014 at 2:05 AM, Grant Edwards  wrote:
> On 2014-11-05, Dennis Lee Bieber  wrote:
>
>>  "machine code" typically implies an instruction set specific
>> to that machine... ALL computers operate in BINARY logic (a bit only
>> holds 0 or 1). How you get those bits into the computer is
>> irrelevant.
>
> Just to muddy the water...
>
> _Most_ parts of most computers operate in binary.  Portions of some
> parts (e.g. some NAND flash) use ternary, quaternary, or octal.  IIRC,
> four-state transistor cells are pretty common at the moment, but some
> vendor(s) are working with 8-state cells.

Dragging this back to some semblance of reality: Whenever you write
code, you're writing code for some kind of executor. No level of
abstraction higher or lower truly matters; you just write to the level
you're aiming at, and everything else is of educational curiosity
only. I might write code for a Python executor one day, and for a C
executor another, and then another day maybe I'm writing LaTeX code -
that's a language, too, of a sort. If I build my own framework layer
above the base executor, that's just added another type of executor to
the pool, and now I can target that. Everything's abstractions around
something, and *it doesn't matter*, because anyone can fiddle with any
layer without disturbing the others. Those eight-state cells can be
dropped in without breaking my Python code - that's the whole point of
abstractions. They're doing their job.

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


Re: Build Question: How to Add -Wl, --option Before Objects In Setup.py?

2014-11-05 Thread Cyd Haselton
On Sun, Nov 2, 2014 at 3:38 PM, Ned Deily  wrote:
> In article
> ,
>  Cyd Haselton  wrote:
>> Just checking: is sincos() the same as sin() and cos()? Nm output for
>> my toolchain's libm does show sin() and cos() just not sincos()
>
> See, this is what you get when you ask for free help: bad info.

Silly me...what was I thinking?

> sincos
> isn't the same, as a little of googling informs me.  But, as the thread
> starting here indicates:
>

I did a fairly exhaustive search for the sincos() error code I was
getting and that link did not turn up for me at all.
Instead I found a reference that seemed to imply that such a macro
should be implemented but it was not implemented
in GCC-4.8.0.

Then again, the link you found doesn't seem to indicate which version
of GCC has this feature...maybe it is versions
later than 4.8.0...


> https://sourceware.org/ml/binutils/2010-04/msg00219.html
>
> gcc can do an optimization that turns a pair of sin() and cos() calls
> with the same arguments into a single call to sincos().  And there is
> such a pair in Python's complexobject.c.  As the thread explains, there
> are some platforms where sin() and cos() are implemented but not
> sincos().  As suggested in the thread, one approach is to give options
> to gcc to avoid the optimizations:
>
> CFLAGS='-fno-builtin-sin -fno-builtin-cos'
>
> That does seem to result in a libpython with no references to sincos.

Sounds good...I'll try it if bootstrapping 4.9.0 goes south.
>
> --
>  Ned Deily,
>  n...@acm.org
>
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread Denis McMahon
On Tue, 04 Nov 2014 21:30:06 -0500, Dennis Lee Bieber wrote:

>   If you have an old system with front-panel toggle switches, you 
set the
> switches for binary values, and then push the "enter" switch.

You've booted a PDP-8 then ;)

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


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Larry Martell
On Wed, Nov 5, 2014 at 7:41 AM, Chris Angelico  wrote:
> On Wed, Nov 5, 2014 at 11:31 PM, Ivan Evstegneev
>  wrote:
 That's what I'm talking about (asking actually), where do you know it from?
>>
I know it because I've been a programmer for 39 years.
>>
>> I didn't intend to offence anyone here. Just asked a questions ^_^
>
> Don't worry about offending people.

Exactly. This is the internet - it's all about annoying people ;-)

> Even if you do annoy one or two,
> there'll be plenty of us who know to be patient :) And I don't think
> Larry was actually offended; it's just that some questions don't
> really have easy answers - imagine someone asking a great
> mathematician "But how do you KNOW that 2 + 2 is 4? Where's it written
> down?"... all he can say is "It is".

Yeah, I'm on a lot of lists and lately I've seen a lot of 'I'm not a
programmer, but I want to write code and I need someone to tell me
how." Gets to you after a while.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Chris Angelico
On Thu, Nov 6, 2014 at 2:56 AM, Larry Martell  wrote:
>> And I don't think
>> Larry was actually offended; it's just that some questions don't
>> really have easy answers - imagine someone asking a great
>> mathematician "But how do you KNOW that 2 + 2 is 4? Where's it written
>> down?"... all he can say is "It is".
>
> Yeah, I'm on a lot of lists and lately I've seen a lot of 'I'm not a
> programmer, but I want to write code and I need someone to tell me
> how." Gets to you after a while.

Too true. Those same people are unlikely to go to a gathering of civil
engineers and say "I'm no expert, but I want to build a bridge and I
need someone to tell me how", yet somehow it's expected to be possible
with software.

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


Real-world use of Counter

2014-11-05 Thread Ethan Furman
I'm looking for real-world uses of collections.Counter, specifically to see if anyone has been surprised by, or had to 
spend extra-time debugging, issues with the in-place operators.


Background:

Most Python data types will cause a TypeError to be raised if unusable types 
are passed in:

--> {'a': 0}.update(5)
TypeError: 'int' object is not iterable

--> [1, 2, 3].extend(3.14)
TypeError: 'float' object is not iterable

--> from collections import Counter
--> Counter() + [1, 2, 3]
TypeError: unsupported operand type(s) for +: 'Counter' and 'list'

Most Counter in-place methods also behave this way:

--> c /= [1, 2, 3]
TypeError: unsupported operand type(s) for /=: 'Counter' and 'list'

However, in the case of a handful of Counter in-place methods (+=, -=, &=, and 
|=), this is what happens instead:

--> c = Counter()
--> c += [1, 2, 3]
AttributeError: 'list' object has no attribute 'items'

Even worse (in my opinion) is the case of an empty Counter `and`ed with an 
incompatible type:

--> c &= [1, 2, 3]
-->

No error is raised at all.

In order to avoid unnecessary code churn (the fix itself is quite simple), the maintainer of the collections module 
wants to know if anybody has actually been affected by these inconsistencies, and if so, whether it was a minor 
inconvenience, or a compelling use-case.


So, if this has bitten you, now is the time to speak up!  :)

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


Misunderstanding buffering - flushing isn't

2014-11-05 Thread Skip Montanaro
I've been developing a little web server. The request handler
subclasses SimpleHTTPRequestHandler. It has a do_GET method which
figures out what work to actually do, then ends with this:

def do_GET(self):
...
sys.stdout.flush()
sys.stderr.flush()

As it's still being actively developed, I've been dumping all sorts of
diagnostic prints to stdout and stderr. I've been running it directly
in a terminal window (this is an openSuSE system), but wanted to
capture stdout and stderr for post-mortem analysis, so I wrote this
little shell script:

#!/bin/bash

PORT=${1:-8008}
BASE=$(dirname $0)

echo port=$PORT pid=$$ > ${PORT}.stdout

while true ; do
python ${BASE}/httpserver.py $PORT >> ${PORT}.stdout 2> ${PORT}.stderr
sleep 1
done

I figured everything would be flushed to the respective .stdout and
.stderr files at the end of every request, but that appears not to be
the case. Do I have to run the python command with the -u flag to
guarantee each request's output is immediately available in the output
file at the end of each request?

Thx,

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


Re: Misunderstanding buffering - flushing isn't

2014-11-05 Thread Skip Montanaro
On Wed, Nov 5, 2014 at 10:44 AM, Skip Montanaro
 wrote:
> I figured everything would be flushed to the respective .stdout and
> .stderr files at the end of every request, but that appears not to be
> the case.

I stand corrected. I added

print ">> request finished"

to the end of do_GET (just before the flush() calls). I see that in
the output files after the request finishes. Maybe I was just
dreaming...

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


Re: Misunderstanding buffering - flushing isn't

2014-11-05 Thread Irmen de Jong
On 5-11-2014 17:44, Skip Montanaro wrote:

> As it's still being actively developed, I've been dumping all sorts of
> diagnostic prints to stdout and stderr.

Any reason you're not using the logging module and get it all nicely dumped 
into a log
file instead?

(asks he who regularly inserts prints himself when doing a debugging task)

Irmen

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


Re: pkcs7 signing

2014-11-05 Thread Irmen de Jong
On 5-11-2014 11:14, Robin Becker wrote:
> On 05/11/2014 06:40, dieter wrote:
>> Robin Becker  writes:
>>
>>> Is there a way to do pkcs7 / 12 signing with python.
>>
>> Have you checked whether "OpenSSL" supports this kind of signing?
>> If it does, then you likely can use this via several Python wrappings
>> for "OpenSSL".
>>
> I checked that the openssl library does have a call for this, however, I 
> cannot see this
> exposed in either the cryptography or py2crypto packages. The code may be in 
> there, but
> I don't see it obviously exposed. I think m2crypto might do the job, but 
> building it for
> windows is a pain and I probably have to build it 6 times ie 32 & 64 bits x 
> 2.7 3.3 &
> 3.4. There are pre-built versions of openssl, but that's also a moving target 
> right now.

If you've got no luck with a direct openssl library, you can also call the 
openssl.exe
binary and capture its results back into Python. You'll have to install 
something on
windows to get that executable though.


Irmen


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


Re: Real-world use of Counter

2014-11-05 Thread Peter Otten
Ethan Furman wrote:

> I'm looking for real-world uses of collections.Counter, specifically to
> see if anyone has been surprised by, or had to spend extra-time debugging,
> issues with the in-place operators.
> 
> Background:
> 
> Most Python data types will cause a TypeError to be raised if unusable
> types are passed in:
> 
> --> {'a': 0}.update(5)
> TypeError: 'int' object is not iterable
> 
> --> [1, 2, 3].extend(3.14)
> TypeError: 'float' object is not iterable
> 
> --> from collections import Counter
> --> Counter() + [1, 2, 3]
> TypeError: unsupported operand type(s) for +: 'Counter' and 'list'
> 
> Most Counter in-place methods also behave this way:
> 
> --> c /= [1, 2, 3]
> TypeError: unsupported operand type(s) for /=: 'Counter' and 'list'
> 
> However, in the case of a handful of Counter in-place methods (+=, -=, &=,
> and |=), this is what happens instead:
> 
> --> c = Counter()
> --> c += [1, 2, 3]
> AttributeError: 'list' object has no attribute 'items'
> 
> Even worse (in my opinion) is the case of an empty Counter `and`ed with an
> incompatible type:
> 
> --> c &= [1, 2, 3]
> -->
> 
> No error is raised at all.
> 
> In order to avoid unnecessary code churn (the fix itself is quite simple),
> the maintainer of the collections module wants to know if anybody has
> actually been affected by these inconsistencies, and if so, whether it was
> a minor inconvenience, or a compelling use-case.
> 
> So, if this has bitten you, now is the time to speak up!  :)

Some more:

>>> Counter(a=1, b=2)
Counter({'b': 2, 'a': 1})
>>> Counter(a=1, b=2, iterable=3)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.4/collections/__init__.py", line 462, in __init__
self.update(iterable, **kwds)
  File "/usr/lib/python3.4/collections/__init__.py", line 542, in update
_count_elements(self, iterable)
TypeError: 'int' object is not iterable

This is just the first oddity I came up with. I expect that the 
possibilities to break Python-coded classes are unlimited, as a result of 
the -- for me -- greatest gift of Python, namely: duck-typing. I hate the 
sum() implementation, not because I ever plan to "add" strings, but because 
it tests against bad style. Consenting adults, where are you?

In particular for the &= fix, would

>>> c = Counter([1, 2])
>>> c &= [1, 2, 3]
>>> c
Counter({1: 1, 2: 1})

still be allowed? If not, are there other places where a sequence might 
pretend to be a mapping?

FTR, as I'm not exactly a power-user of Counter, I think I have used only 
the initializer with one positional iterable, and most_common(), and thus 
never been bitten by any of the above pitfalls.


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


Re: I need algorithm for my task

2014-11-05 Thread MRAB

On 2014-11-05 11:58, lordvita...@gmail.com wrote:

I have line 'pythonpythonpyth'. How do I know which word is the foundation 
line?.
Other examples:
"pythonpythonpyth" is python
"DOLORIUMD" is DOLORIUM
"HELLOLHELLO" is HELLOL
"thewordword" is thewordword

I need to know whether the word in the text is repeated and get it. This will 
be the key.


Consider the first example.

If the foundation is the first 1 character 'p' and you repeat it enough
times you'll get ''.

This is the same length as the line.

Does it match the line? No.

OK.

If the foundation is the first 2 characters 'py' and you repeat it
enough times you'll get 'pypypypypypypypy'.

This is the same length as the line.

Does it match the line? No.

OK.

If the foundation is the first 3 characters 'py' and you repeat it
enough times you'll get 'pytpytpytpytpytpyt'.

This is longer than as the line, so truncate it to 'pytpytpytpytpytpy'.

Does it match the line? No.

OK.

Continue in this vein until you'll get a match. (The foundation might
in fact be the entire line.)

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


Re: Misunderstanding buffering - flushing isn't

2014-11-05 Thread Skip Montanaro
On Wed, Nov 5, 2014 at 11:29 AM, Irmen de Jong  wrote:
> Any reason you're not using the logging module and get it all nicely dumped 
> into a log
> file instead?

I'm an old fart. What can I say? BITD, (as Irmen is well aware, being
about as old as I am in Python years), print was all we had. (We also
walked uphill to school in both directions, in the snow.) While I use
the logging module in other contexts, I never really liked it, and
generally use it grudgingly.

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


Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread MRAB

On 2014-11-05 02:30, Dennis Lee Bieber wrote:

On Tue, 4 Nov 2014 13:45:32 -0300, françai s 
declaimed the following:


I intend to write in lowest level of computer programming as a hobby.

It is true that is impossible write in binary code, the lowest level
of programming that you can write is in hex code?

What is the lowest level of programming computers that you can write ?

Is binary code?

Is hex code?

Is another machine code? Honestly do not know if it is true that there
is another machine code beyond the binary and hex code.

Is Assembly?


Meaningless question -- it all relies upon HOW THE CODE GETS INTO
MEMORY.

NOT TO MENTION: "binary" and "hex" are just notations. They both
represent a set of bits, but hex uses one character to encode 4 bits while

binary needs one character for each bit.

0xA5 is the SAME as '101001010'b (note: the notation differs with
whatever system you use to enter them -- 0xA5 in C is 16#A5# in Ada, and
'A5'h in some obsolete systems..


I've also seen $A3 and 0A3h (it needs to start with a digit in the
range 0..9).


If you have an old system with front-panel toggle switches, you set the
switches for binary values, and then push the "enter" switch.

"machine code" typically implies an instruction set specific to that
machine... ALL computers operate in BINARY logic (a bit only holds 0 or 1).
How you get those bits into the computer is irrelevant.



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


Re: Misunderstanding buffering - flushing isn't

2014-11-05 Thread Chris Angelico
On Thu, Nov 6, 2014 at 4:54 AM, Skip Montanaro  wrote:
> I'm an old fart. What can I say? BITD, (as Irmen is well aware, being
> about as old as I am in Python years), print was all we had. (We also
> walked uphill to school in both directions, in the snow.) While I use
> the logging module in other contexts, I never really liked it, and
> generally use it grudgingly.

I have nothing against print... as long as it's a function. I don't
like the arcane notations shoehorned into the print statement (the >>
syntax always trips me up, I'm never sure whether to put it at the
beginning or the end - it's ugly either way), but the function behaves
nicely.

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


Re: I need algorithm for my task

2014-11-05 Thread C@rlos
I thing this work: 

stg='pythonpython' 
foundationline=stg[ 0:( stg [ 1: ].index( stg[ 0 ])+1 ) ] 

On 2014-11-05 11:58, lordvita...@gmail.com wrote: 
> I have line 'pythonpythonpyth'. How do I know which word is the foundation 
> line?. 
> Other examples: 
> "pythonpythonpyth" is python 
> "DOLORIUMD" is DOLORIUM 
> "HELLOLHELLO" is HELLOL 
> "thewordword" is thewordword 
> 
> I need to know whether the word in the text is repeated and get it. This will 
> be the key. 
> 
Consider the first example. 

If the foundation is the first 1 character 'p' and you repeat it enough 
times you'll get ''. 

This is the same length as the line. 

Does it match the line? No. 

OK. 

If the foundation is the first 2 characters 'py' and you repeat it 
enough times you'll get 'pypypypypypypypy'. 

This is the same length as the line. 

Does it match the line? No. 

OK. 

If the foundation is the first 3 characters 'py' and you repeat it 
enough times you'll get 'pytpytpytpytpytpyt'. 

This is longer than as the line, so truncate it to 'pytpytpytpytpytpy'. 

Does it match the line? No. 

OK. 

Continue in this vein until you'll get a match. (The foundation might 
in fact be the entire line.) 

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

III Escuela Internacional de Invierno en la UCI del 17 al 28 de febrero del 
2014. Ver www.uci.cu-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I need algorithm for my task

2014-11-05 Thread MRAB

On 2014-11-05 18:05, C@rlos wrote:

I thing this work:

stg='pythonpython'
foundationline=stg[ 0:( stg [ 1: ].index( stg[ 0 ])+1 ) ]


It doesn't work for the final example or "barbaz".

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


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Neil D. Cerutti

On 11/5/2014 7:41 AM, Chris Angelico wrote:

On Wed, Nov 5, 2014 at 11:31 PM, Ivan Evstegneev
 wrote:

That's what I'm talking about (asking actually), where do you know it from?



I know it because I've been a programmer for 39 years.


I didn't intend to offence anyone here. Just asked a questions ^_^


Don't worry about offending people. Even if you do annoy one or two,
there'll be plenty of us who know to be patient :) And I don't think
Larry was actually offended; it's just that some questions don't
really have easy answers - imagine someone asking a great
mathematician "But how do you KNOW that 2 + 2 is 4? Where's it written
down?"... all he can say is "It is".


But it *can* be interesting to try and do otherwise. 
http://en.wikipedia.org/wiki/Principia_Mathematica


--
Neil Cerutti

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


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Terry Reedy

On 11/5/2014 7:31 AM, Ivan Evstegneev wrote:

You got my point exactly. ^_^ This is not about a "range" command
itself, but those conventions.


The Language Manual 1. Introduction has a section on the grammar 
notation conventions.  The Library Manual 1. Introduction does not.  I 
would agree that it should.  Someone could open an issue.


Ivan, the help(ob) results sometimes assume that you have read the doc 
and only need a reminder about the function signature.  I strongly 
recommend that you read most of the first 5 chapter of the Library 
manual, especially 2 and 4.


--
Terry Jan Reedy

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


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Gene Heskett
On Wednesday 05 November 2014 10:56:57 Larry Martell did opine
And Gene did reply:
> On Wed, Nov 5, 2014 at 7:41 AM, Chris Angelico  wrote:
> > On Wed, Nov 5, 2014 at 11:31 PM, Ivan Evstegneev
> > 
> >  wrote:
>  That's what I'm talking about (asking actually), where do you know
>  it from?
> 
> I know it because I've been a programmer for 39 years.
> >> 
> >> I didn't intend to offence anyone here. Just asked a questions ^_^
> > 
> > Don't worry about offending people.
> 
> Exactly. This is the internet - it's all about annoying people ;-)
> 
> > Even if you do annoy one or two,
> > there'll be plenty of us who know to be patient :) And I don't think
> > Larry was actually offended; it's just that some questions don't
> > really have easy answers - imagine someone asking a great
> > mathematician "But how do you KNOW that 2 + 2 is 4? Where's it
> > written down?"... all he can say is "It is".
> 
> Yeah, I'm on a lot of lists and lately I've seen a lot of 'I'm not a
> programmer, but I want to write code and I need someone to tell me
> how." Gets to you after a while.

+1000, and its not just this list Larry.  It seems we have a pandemic.

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


Re: detect mouse pointer type

2014-11-05 Thread Joel Goldstick
On Tue, Nov 4, 2014 at 9:07 PM, Peter Irbizon  wrote:
> Hello,
> please how can I detect mouse pointer type? I would like to print every
> mouse pointer change (arrow, hand, ...) while moving my mouse over screen.
> How can I do this? (for now I need it for windows, but cross-platform
> solution is highly appreciated)
>
Those events happen in the browser.  I suspect you could do this with
javascript.  Can't do it on the backend.

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



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


Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread Cameron Simpson

On 05Nov2014 15:38, Denis McMahon  wrote:

On Tue, 04 Nov 2014 21:30:06 -0500, Dennis Lee Bieber wrote:

  If you have an old system with front-panel toggle switches, you

set the

switches for binary values, and then push the "enter" switch.


You've booted a PDP-8 then ;)


Not me, but I have booted a PDP-11. Same deal:-)

Our kernels had a patch in the idle loop that updated a specific memory address 
with a regularly changing bit pattern (therefore the change rate slowed down 
when the machine was busy). Post boot we'd set the memory view toggle swithces 
to that address and be treated to a beautiful Cylon-like shuttling pattern of 
red lights indiciating business.


Cheers,
Cameron Simpson 

The most likely way for the world to be destroyed, most experts agree, is by
accident. That's where we come in; we're computer professionals. We cause
accidents.  - Nathaniel Borenstein
--
https://mail.python.org/mailman/listinfo/python-list


Re: detect mouse pointer type

2014-11-05 Thread Marc Aymerich
On Wed, Nov 5, 2014 at 11:31 PM, Joel Goldstick 
wrote:

> On Tue, Nov 4, 2014 at 9:07 PM, Peter Irbizon 
> wrote:
> > Hello,
> > please how can I detect mouse pointer type? I would like to print every
> > mouse pointer change (arrow, hand, ...) while moving my mouse over
> screen.
> > How can I do this? (for now I need it for windows, but cross-platform
> > solution is highly appreciated)
> >
> Those events happen in the browser.  I suspect you could do this with
> javascript.  Can't do it on the backend.
>



Back in the day we used to have desktop applications other than the web
browser. But this was even before cloud computing began to emerge ;)


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


Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread Dan Stromberg
On Tue, Nov 4, 2014 at 10:39 PM, Cameron Simpson  wrote:
> Bah! He asked if there were lower levels than binary. Ergo: chip design!
> (And microcode, the intermediate layer. Or one of the layers, depending
> where you draw the line.) Should we stop before we reach the quantum foam of
> spacetime?

Last I heard, Intel (and others?) had stopped using microcode, to get
a performance boost.  That means CPU's are not field-updatable in the
event of a problem, but most people would just buy another computer
anyway.
-- 
https://mail.python.org/mailman/listinfo/python-list


Machine Learning Startup Hiring

2014-11-05 Thread Charles Weitzer
My name is Charles Weitzer. I do recruiting with a focus on quantitative 
sciences. One of my clients is a machine learning startup
located in Northern California. The founders include a successful veteran 
entrepreneur with a PhD in CS from Stanford, while the
other founder is on the faculty at UC Berkeley. Their team has made unpublished 
discoveries in the field of Machine Learning and in
other areas as well.  

My client would like to hire an extremely talented Senior Data Infrastructure 
Software Engineer as soon as possible. Their job
description can be found below. This group is going to be the next big thing in 
terms of quantitative strategies and systems.  They
are rebuilding their current system and also designing a new system.  You could 
work on either or both. I would love to speak with
you or anyone else you might highly recommend about this opportunity.

Thank you,

Charles Weitzer

CEO/Senior Recruiter
Charles Weitzer and Associates, Inc.
Global Financial Recruiting Services
Email: char...@charlesweitzer.com
Phone: (USA) 510 558-9182

*
Senior Data Infrastructure Software Engineer

Fast-growing science and technology-driven startup seeks a Senior Data 
Infrastructure Software Engineer. You will be a core member
working with the RnD, Software, Infrastructure, and Trading teams to develop, 
test, deploy, and manage research, operational and
production software. 

The firm researches and deploys machine learning and statistical trading 
strategies that are designed to generate attractive returns
without being dependent on the performance of the overall market.  Join a team 
of people that includes a professor at a premier
university as well as over ten PhDs and two MBAs from top schools, led by the 
founder and CEO of a successful Internet
Infrastructure technology firm. We have a casual and collegial office 
environment, weekly catered lunches, and offer competitive
benefits packages. 

Focus areas for the position include creating software infrastructure for our 
research department and production trading systems,
implementing and automating back office and reporting systems, as well as 
supporting the next generation of our compute and storage
hardware systems. We seek a candidate who can bring both development and 
operations skills to rework existing software
infrastructure and guide test/automation of new and ongoing deployments.

Qualifications:

.   Experience writing Python code in a *nix environment
.   Experience working with mission critical RDBMS, performance and fault 
tolerance
.   Industry experience as a software engineer
.   Automation deployment and virtualization (Ansible, KVM, Jenkins, etc.)
.   Experience with debugging and performance profiling, including the use 
of tools such as strace, valgrind, gdb, tcpdump, etc.

Useful Skills (Desirable, but not required):

.   Monitor and network management (Nagios, Logstash, Graphite, Cacti, etc.)
.   Knowledge of distributed systems, cluster computing, and fault tolerance
.   Experience making commits on open-source technology
.   Familiarity with cluster management and job queuing systems (Chronos, 
Luigi, Oracle grid engine, Mesos, etc.)
.   Experience in operations for highly available services

Please note that a background in finance is not required.

*
To apply for this position, please send your resume to 
char...@charlesweitzer.com.

Thank you,

Charles Weitzer

CEO/Senior Recruiter
Charles Weitzer and Associates, Inc.
Global Financial Recruiting Services
Email: char...@charlesweitzer.com
Phone: (USA) 510 558-9182



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


Re: [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread Cameron Simpson

On 05Nov2014 18:09, Chris Angelico  wrote:

On Wed, Nov 5, 2014 at 5:39 PM, Cameron Simpson  wrote:

Bah! He asked if there were lower levels than binary. Ergo: chip design!
(And microcode, the intermediate layer. Or one of the layers, depending
where you draw the line.) Should we stop before we reach the quantum foam of
spacetime?


Certainly not. We keep going below electrons, and find ourselves in
Quantumland. It's like Wonderland, only... uhh... actually, it's just
like Wonderland. Pick up a book called "Alice in Quantumland" by
Robert Gilmore - it's worth reading.


It is sitting of the shelf right here, awaiting my attention:-)

Cheers,
Cameron Simpson 

If this experiment we're doing works, then I will follow up and push it as
hard as possible. And if it doesn't work, I will write a science-fiction
novel where it does work. It's a win-win situation.
- John Cramer on his experiment for possible cuasality violation
--
https://mail.python.org/mailman/listinfo/python-list


Re: Misunderstanding buffering - flushing isn't

2014-11-05 Thread Mark Lawrence

On 05/11/2014 17:54, Skip Montanaro wrote:

On Wed, Nov 5, 2014 at 11:29 AM, Irmen de Jong  wrote:

Any reason you're not using the logging module and get it all nicely dumped 
into a log
file instead?


I'm an old fart. What can I say? BITD, (as Irmen is well aware, being
about as old as I am in Python years), print was all we had. (We also
walked uphill to school in both directions, in the snow.) While I use
the logging module in other contexts, I never really liked it, and
generally use it grudgingly.

Skip



My approach was much like yours but I was converted a couple of years 
ago.  Sadly both the name of the author and the title of the article 
left, as the late, great Spike Milligan said in one of his books, "an 
indelible blank on my mind" :)


However in an attempt to show that you can teach a fellow old fart new 
tricks could an article like this help 
http://fruch.github.io/2014/11/06/taming-the-logging-formatter/ ?


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re:[OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-05 Thread Dave Angel
françai s  Wrote in message:
> I intend to write in lowest level of computer programming as a hobby.
> 
> It is true that is impossible write in binary code, the lowest level
> of programming that you can write is in hex code?
> 
> What is the lowest level of programming computers that you can write ?
> 
> Is binary code?
> 
> Is hex code?
> 
> Is another machine code? Honestly do not know if it is true that there
> is another machine code beyond the binary and hex code.
> 
> Is Assembly?
> 

You have to start somewhere. The lowest practical level is called
 hardware. If you're going to ignore that, then you presumably
 have some particular hardware in mind. If you're talking the
 Intel Pentium, you've already skipped the lowest level, because
 Intel has already done it (microcode ) and sealed it inside the
 chip.

Many years ago I wrote microcode for a living,  and on some of our
 machines it was buried in ROM, while in others it was changeable
 and loaded at boot time. In any case, customers didn't usually
 get documentation or tools for changing it. There probably are
 still processors around that have changeable microcode
 available.

You may ask what is Microcode? It's the code that tells the real
 hardware what to do with that binary "machine code" that people
 call machine code. You don't really think that there is hardware
 to do a trig function,  do you?

So once you pick a processor, if you can't write the microcode, 
 what's the lowest level? Toggle switches is probably it, because
 anything else has gobs of software running before you hit your
 first key. Keyboards were once hardware, but probably any recent
 keyboard has more code in it than my satellite navigation program
 written in 1973.

Of course toggle switches on the console are probably binary, but
 the first IBM machines had hex rotary switches on their
 console.

There's no important difference between binary and hex; you do
 those conversions in your head while toggling stuff
 in.

Now if you don't have a console then you have to go up a level, 
 and use some form of console. We used punched paper tape as the
 next level up, and hex punched cards next. I suppose you'll have
 to use a console,  with some kind of monitor echoing your
 keystrokes onto a screen. No tty for you?

Next level up is to have some form of operating system running. 
 You might even use a system call to output a character to your
 terminal. No machine language instruction for that.

And so on.

Assembly is a low level language that is pretty much translated,
 each line of text into one mahine instruction. Usually the
 printout can show the results in hex or octal, but you can
 trivially convert in your head to binary for those toggle
 switches or whatever.  Or use the executable that your assembler
 and linker produce. But by now you're using lots of os services, 
 reading and writing files, displaying stuff, printing to a dot
 matrix or daisy wheel printer.

Pick your level, there are dozens, and I've used most of them. But
 the distinction between binary, octal, and hex is too minor to
 mention,  except you specifically asked.

HTH

-- 
DaveA

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


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Dave Angel
Chris Angelico  Wrote in message:
> On Thu, Nov 6, 2014 at 2:56 AM, Larry Martell  wrote:
>>> And I don't think
>>> Larry was actually offended; it's just that some questions don't
>>> really have easy answers - imagine someone asking a great
>>> mathematician "But how do you KNOW that 2 + 2 is 4? Where's it written
>>> down?"... all he can say is "It is".
>>
>> Yeah, I'm on a lot of lists and lately I've seen a lot of 'I'm not a
>> programmer, but I want to write code and I need someone to tell me
>> how." Gets to you after a while.
> 
> Too true. Those same people are unlikely to go to a gathering of civil
> engineers and say "I'm no expert, but I want to build a bridge and I
> need someone to tell me how", yet somehow it's expected to be possible
> with software.
> 
> ChrisA
> 

Or I'm no expert but I need someone to show me how; build me one
 here in my front yard.
-- 
DaveA

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


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Mark Lawrence

On 06/11/2014 02:37, Dave Angel wrote:

Chris Angelico  Wrote in message:

On Thu, Nov 6, 2014 at 2:56 AM, Larry Martell  wrote:

And I don't think
Larry was actually offended; it's just that some questions don't
really have easy answers - imagine someone asking a great
mathematician "But how do you KNOW that 2 + 2 is 4? Where's it written
down?"... all he can say is "It is".


Yeah, I'm on a lot of lists and lately I've seen a lot of 'I'm not a
programmer, but I want to write code and I need someone to tell me
how." Gets to you after a while.


Too true. Those same people are unlikely to go to a gathering of civil
engineers and say "I'm no expert, but I want to build a bridge and I
need someone to tell me how", yet somehow it's expected to be possible
with software.

ChrisA



Or I'm no expert but I need someone to show me how; build me one
  here in my front yard.



Against a requirements specification that changes on a daily basis, I 
want it delivered yesterday and no you can't have any more resources to 
help out, so don't ask :)


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: I need algorithm for my task

2014-11-05 Thread Denis McMahon
On Wed, 05 Nov 2014 18:49:01 +, MRAB wrote:

> On 2014-11-05 18:05, C@rlos wrote:
>> I thing this work:
>>
>> stg='pythonpython'
>> foundationline=stg[ 0:( stg [ 1: ].index( stg[ 0 ])+1 ) ]
>>
> It doesn't work for the final example or "barbaz".

I have two algorithms I've implemented.

Still not sure exactly which algorithm he wants though. The first one is 
as he describes, in that the word is only reported if it's repeated, else 
report the whole string.

The second algorithm reads up until the first letter is repeated, or 
reports the whole string if no repeat found.

I did see a third algorithm suggested, I should add that and see what 
happens.

OK, implemented the third algorithm (repeat first n chars of s int(n/len
(s))+1 times, truncate to len(s) and compare with s), I also added 
another test case, now my test cases are:

t = ["pythonpythonpyth", "DOLORIUMD", "HELLOLHELLO", "thewordword", 
"barbaz", "dibdibdobdibdibdob"]

and my output is:

$ ./words.py

python DOLORIUMD HELLOLHELLO thewordword barbaz dib

python DOLORIUM HELLOL thewordword bar dib

python DOLORIUM HELLOL thewordword barbaz dibdibdob

$

I wonder which of these three is actually the algorithm the OP wants.

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


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Chris Angelico
On Thu, Nov 6, 2014 at 1:52 PM, Mark Lawrence  wrote:
> Against a requirements specification that changes on a daily basis, I want
> it delivered yesterday and no you can't have any more resources to help out,
> so don't ask :)

Or maybe "Look, I'll give you five bucks if you can have the whole
thing done by tomorrow, okay?"...

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


Re: I need algorithm for my task

2014-11-05 Thread Denis McMahon
On Wed, 05 Nov 2014 18:49:01 +, MRAB wrote:

> It doesn't work for the final example or "barbaz".

Oh, and we really need a private "python homework answers" list where we 
can discuss the most pythonic solution we can think of for all these 
homework / coursework questions without showing the solutions to the 
students.

I'm quite proud of a 2 line solution to the third algorithm that I 
implemented, although it might be considered as somewhat obfuscated code 
by some. ;)

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


Re: I need algorithm for my task

2014-11-05 Thread Chris Angelico
On Thu, Nov 6, 2014 at 2:36 PM, Denis McMahon  wrote:
> On Wed, 05 Nov 2014 18:49:01 +, MRAB wrote:
>
>> It doesn't work for the final example or "barbaz".
>
> Oh, and we really need a private "python homework answers" list where we
> can discuss the most pythonic solution we can think of for all these
> homework / coursework questions without showing the solutions to the
> students.
>
> I'm quite proud of a 2 line solution to the third algorithm that I
> implemented, although it might be considered as somewhat obfuscated code
> by some. ;)

Fun way to handle that: You get access only when you demonstrate that
you can write a (mostly-)working version yourself.

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


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Gene Heskett
On Wednesday 05 November 2014 21:52:42 Mark Lawrence did opine
And Gene did reply:
> On 06/11/2014 02:37, Dave Angel wrote:
> > Chris Angelico  Wrote in message:
> >> On Thu, Nov 6, 2014 at 2:56 AM, Larry Martell 
 wrote:
>  And I don't think
>  Larry was actually offended; it's just that some questions don't
>  really have easy answers - imagine someone asking a great
>  mathematician "But how do you KNOW that 2 + 2 is 4? Where's it
>  written down?"... all he can say is "It is".
> >>> 
> >>> Yeah, I'm on a lot of lists and lately I've seen a lot of 'I'm not
> >>> a programmer, but I want to write code and I need someone to tell
> >>> me how." Gets to you after a while.
> >> 
> >> Too true. Those same people are unlikely to go to a gathering of
> >> civil engineers and say "I'm no expert, but I want to build a
> >> bridge and I need someone to tell me how", yet somehow it's
> >> expected to be possible with software.
> >> 
> >> ChrisA
> > 
> > Or I'm no expert but I need someone to show me how; build me one
> > 
> >   here in my front yard.
> 
> Against a requirements specification that changes on a daily basis, I
> want it delivered yesterday and no you can't have any more resources to
> help out, so don't ask :)
With, or without a toll booth and operator?

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


Re: I need algorithm for my task

2014-11-05 Thread Denis McMahon
On Thu, 06 Nov 2014 03:36:40 +, Denis McMahon wrote:

> On Wed, 05 Nov 2014 18:49:01 +, MRAB wrote:
> 
>> It doesn't work for the final example or "barbaz".
> 
> Oh, and we really need a private "python homework answers" list where we
> can discuss the most pythonic solution we can think of for all these
> homework / coursework questions without showing the solutions to the
> students.

> I'm quite proud of a 2 line solution to the third algorithm that I
> implemented, although it might be considered as somewhat obfuscated code
> by some. ;)

Even prouder of the 1 liner!

In fact I'm going to post it, because I think any student who can walk 
his instructor through how my one-liner works deserves the marks. Of 
course, any student who presents this as a solution and is unable to walk 
their instructor through it should be failed for stupidity and plagiarism!

t = ["pythonpythonpyth", "DOLORIUMD", "HELLOLHELLO", "thewordword", 
"barbaz", "dibdibdobdibdibdob"]

def baseword(s):
"""find shortest sequence which repeats to generate s"""
return s[0:["".join([s[0:x]for k in range(int(len(s)/x)+1)])[0:len
(s)]for x in range(1,len(s)+1)].index(s)+1]

for w in t:

print(baseword(w))

p.s. I really want to be in the room when the instructor asks this 
student to come up in front of the class and explain how his solution 
works!

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


Re: Misunderstanding buffering - flushing isn't

2014-11-05 Thread Dave Angel
Skip Montanaro  Wrote in message:
> On Wed, Nov 5, 2014 at 10:44 AM, Skip Montanaro
>  wrote:
>> I figured everything would be flushed to the respective .stdout and
>> .stderr files at the end of every request, but that appears not to be
>> the case.
> 
> I stand corrected. I added
> 
> print ">> request finished"
> 
> to the end of do_GET (just before the flush() calls). I see that in
> the output files after the request finishes. Maybe I was just
> dreaming...
> 
> S
> 

Wild guess here. I've worked in environments where a newline would
 trigger a flush.  To check that,  try a trailing comma on the
 last print, which suppresses the newline.
-- 
DaveA

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


Re: I need algorithm for my task

2014-11-05 Thread Chris Angelico
On Thu, Nov 6, 2014 at 3:00 PM, Denis McMahon  wrote:
> def baseword(s):
> """find shortest sequence which repeats to generate s"""
> return s[0:["".join([s[0:x]for k in range(int(len(s)/x)+1)])[0:len
> (s)]for x in range(1,len(s)+1)].index(s)+1]

That's hardly a PEP-8 compliant line, but I can help out a bit.

return s[0:[(s[0:x]*(len(s)//x+1))[0:len(s)]for x in
range(1,len(s)+1)].index(s)+1]

That's still 83 characters without indentation, but it's close now.

I love the algorithm. Took me a bit of analysis (and inspection of
partial results) to understand what your code's doing, but it's
stupidly elegant and elegantly stupid.

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


Re: I need algorithm for my task

2014-11-05 Thread Denis McMahon
On Thu, 06 Nov 2014 15:14:05 +1100, Chris Angelico wrote:

> On Thu, Nov 6, 2014 at 3:00 PM, Denis McMahon 
> wrote:
>> def baseword(s):
>> """find shortest sequence which repeats to generate s"""
>> return s[0:["".join([s[0:x]for k in range(int(len(s)/x)+1)])[0:len
>> (s)]for x in range(1,len(s)+1)].index(s)+1]
> 
> That's hardly a PEP-8 compliant line, but I can help out a bit.
> 
> return s[0:[(s[0:x]*(len(s)//x+1))[0:len(s)]for x in
> range(1,len(s)+1)].index(s)+1]
> 
> That's still 83 characters without indentation, but it's close now.

l = len
r = range

but technically then it's no longer a one liner.

> I love the algorithm. Took me a bit of analysis (and inspection of
> partial results) to understand what your code's doing, but it's stupidly
> elegant and elegantly stupid.

:)

Well yes, building that list is a stupid way to solve the problem, but I 
can't see another way to do it in one line. It's an implementation of my 
algorithm 3 (which I think you described) but working from the other end 
as it were.

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


Re: Real-world use of Counter

2014-11-05 Thread Rustom Mody
On Wednesday, November 5, 2014 9:57:08 PM UTC+5:30, Ethan Furman wrote:
> In order to avoid unnecessary code churn (the fix itself is quite simple), 
> the maintainer of the collections module 
> wants to know if anybody has actually been affected by these inconsistencies, 
> and if so, whether it was a minor 
> inconvenience, or a compelling use-case.
> 
> So, if this has bitten you, now is the time to speak up!  :)


Not in direct answer to your specific question, but Counter generally.

In studying (somewhat theoretically) the general world of 
collection data structures we see
- sets  -- neither order nor repetition
- bags  -- no order, repetition significant
- lists -- both order and repetition

Sometimes 'bag' is called 'multiset'
However counter is a weird non-standard name that overloads
an already overloaded term -- 'Counter' has a very standard meaning in 
programming and in hardware design.

Yes changing the name is too code-churn causing.
But a synonym Bag (or multiset) for Counter would be a pleasant
addition for me.

Calling a bag as counter is inappropriate for an analogous reason
to why calling a dictionary as a 'hash' is inappropriate --
it confuses an implementation detail for fundamental semantics.


PS. I probably wont participate in this discussion hereafter because off-net 
for 2 weeks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Larry Hudson

On 11/05/2014 03:00 AM, Ivan Evstegneev wrote:

Hello everyone,

I’m a Python beginner and just getting familiar with it. (I need it for my EE 
B.Sc. project)
For the learning purposes I use IDLE and (Learning Python by written by Mark 
Lutz).
Let’s say that I have some earlier experience with C language, but still Python 
is a different
one )))


The Lutz book is an excellent and VERY thorough Python reference, but it is not very good as a 
beginner's tutorial.  The standard Python.org tutorial can be a better starting point.  Of 
course, there are a lot of other good sources as well -- both on-line and dead-tree versions. 
Try some googling.  Also the Python Wiki has a lot of valuable links:


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

 -=- Larry -=-

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