Re: Basic Python Questions - Oct. 31, 2013

2013-11-03 Thread rusi
On Sunday, November 3, 2013 11:15:48 AM UTC+5:30, E.D.G. wrote:
> "rusi"  wrote:

> >>Not sure what will… you may look at Julia: http://julialang.org/

>That program language speed comparison table looks quite interesting. 
> And I asked some of the other people that I work with to take a look at the 
> Web page. One or two of them might want to consider using it instead of 
> XBasic assuming the calculation speeds and chart generation capabilities are 
> at least roughly equal. If either of them decides to move in that direction 
> I will probably try using it myself.

And please post back your findings when you have some concrete data

For the record I have exactly zero experience with Julia.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: zero argument member functions versus properties

2013-11-03 Thread Peter Cacioppi
Steve said:

"(This isn't Java or Ruby, where data-hiding is compulsory :-)  " (You could 
add C++ and C# to this list).

This is golden nugget for me. The old synapses are pretty well grooved to think 
of data hiding as good hygiene. Even though I've read a fair bit of Python text 
I still need to be reminded of the little idiomatic differences between Py and 
all the languages made obsolete by Py ;) Thanks.






 

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


Re: Basic Python Questions - Oct. 31, 2013

2013-11-03 Thread Steven D'Aprano
On Sun, 03 Nov 2013 01:02:24 -0500, E.D.G. wrote:

[...]
> Since Perl has a calculation speed
> limit that is probably not easy to get around, before too long another
> language will be selected for initially doing certain things such as
> performing calculations and plotting charts. And the existing Perl code
> might then be gradually translated into that new language.

The nice things about Python are that it makes a great glue language for 
putting together components written in low-level languages like C and 
Fortran, and that there is a rich ecosystem of products for speeding it
up in various ways. So when you hit the speed limits of pure Python, you
have lots of options. In no particular order:


* try using another Python compiler: PyPy is probably the most 
  mature of the stand-alone optimizing compilers, and you can 
  expect to double the speed of "typical" Python code, but 
  there are others;

* use numpy and scipy for vectorized mathematical routines;

* re-write critical code as C or Fortran libraries;

* use Pyrex (possibly unmaintained now) or Cython to write
  C extensions in a Python-like language;

* use Psyco or Numba (JIT specialising compilers for Python);

* use Theano (optimizing computer algebra system compiler);

* use ctypes to call C functions directly;

* use other products like Boost, Weave, and more.


See, for example:

http://jakevdp.github.io/blog/2013/06/15/numba-vs-cython-take-2/

http://technicaldiscovery.blogspot.com.au/2011/06/speeding-up-python-numpy-cython-and.html



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


Re: zero argument member functions versus properties

2013-11-03 Thread Peter Cacioppi
Steve said:

"(This isn't Java or Ruby, where data-hiding is compulsory :-)  "

At the risk of striking a sessile equine, when the attribute shouldn't be 
modified directly by client code, then you hide it and use a property to allow 
client code access. It is the idiom of allowing client code to edit read-write 
data directly via attributes that is pythonic, even though discouraged 
(somewhat) in other languages. 

Actually C# is mature enough for this idiom. C# and Python both support 
getter/setter methods that present as direct attribute access to client code, 
and thus allow you to refactor the class without breaking backwards 
compatibility.

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


Re: zero argument member functions versus properties

2013-11-03 Thread Ian Kelly
On Sun, Nov 3, 2013 at 1:06 AM, Peter Cacioppi  wrote:
> Actually C# is mature enough for this idiom. C# and Python both support 
> getter/setter methods that present as direct attribute access to client code, 
> and thus allow you to refactor the class without breaking backwards 
> compatibility.

It's not as clear-cut as it looks in C#.  Although refactoring the
class in this way doesn't change the API, it does break ABI, which is
significant in an environment where virtually everything is
distributed in binary form.  This happens because a property access
compiled to CIL byte code is transformed into a call to a getter or
setter method, which is a distinct operation from an ordinary
attribute access.  Whereas in Python, an attribute access is just
compiled as an attribute access no matter what the underlying
implementation of that access may end up being at run-time.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Basic Python Questions - Oct. 31, 2013

2013-11-03 Thread E.D.G.
"Steven D'Aprano"  wrote in message 
news:5275fe91$0$29972$c3e8da3$54964...@news.astraweb.com...



http://jakevdp.github.io/blog/2013/06/15/numba-vs-cython-take-2/

http://technicaldiscovery.blogspot.com.au/2011/06/speeding-up-python-numpy-cython-and.html


  It appears that Python can do what is needed.  And if the people that 
I work with want to move in that direction I will probably post a note here 
stating, "This is exactly what we need to do.  What would be the best Python 
download and compiler to do that?"


 It should be a simple matter to determine which compiler and libraries 
etc. should be used.


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


Re: How to add a current string into an already existing list

2013-11-03 Thread Antoon Pardon
Op 03-11-13 07:06, Gregory Ewing schreef:
> Nick the Gr33k wrote:
>> I just want a mysql column type that can be eligible to store an array of 
>> elements, a list that is, no need for having a seperate extra table for that 
>> if we can have a column that can store a list of values.
> 
> Relational database systems typically don't provide any
> such type, because it's not the recommended way of storing
> that kind of data in a relational database.
> 
> The recommended way is to use a secondary table, as has
> been pointed out.
> 
> You're making things difficult for yourself by refusing
> to consider that solution.
> 
You are talking to Nikos! The person who choose code because
he prefers how it looks over examples of working code.

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


Re: Basic Python Questions - Oct. 31, 2013

2013-11-03 Thread Mark Lawrence

On 03/11/2013 09:47, E.D.G. wrote:

"Steven D'Aprano"  wrote in
message news:5275fe91$0$29972$c3e8da3$54964...@news.astraweb.com...


http://jakevdp.github.io/blog/2013/06/15/numba-vs-cython-take-2/

http://technicaldiscovery.blogspot.com.au/2011/06/speeding-up-python-numpy-cython-and.html



   It appears that Python can do what is needed.  And if the people
that I work with want to move in that direction I will probably post a
note here stating, "This is exactly what we need to do.  What would be
the best Python download and compiler to do that?"

  It should be a simple matter to determine which compiler and
libraries etc. should be used.



I've literally just stumbled across this, I've no idea whether it's of 
any use to you https://speakerdeck.com/ianozsvald/high-performance-python


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: multiprocessing: child process race to answer

2013-11-03 Thread cappleman
On Friday, November 1, 2013 10:35:47 PM UTC-4, smhall05 wrote:
> I am using a basic multiprocessing snippet I found:
> 
> 
> 
> #-
> 
> from multiprocessing import Pool
> 
> 
> 
> def  f(x):
> 
> return x*x
> 
> 
> 
> if __name__ == '__main__':
> 
> pool = Pool(processes=4)  # start 4 worker processes
> 
> result = pool.apply_async(f, [10])# evaluate "f(10)" asynchronously
> 
> print result.get(timeout=1)   
> 
> print pool.map(f, range(10))  # prints "[0, 1, 4,..., 81]"
> 
> #-
> 
> 
> 
> I am using this code to have each process go off and solve the same problem, 
> just with different inputs to the problem. I need to be able to kill all 
> processes once 1 of n processes has come up with the solution. There will 
> only be one answer.
> 
> 
> 
> I have tried:
> 
> 
> 
> sys.exit(0) #this causes the program to hang
> 
> pool.close()
> 
> pool.terminate
> 
> 
> 
> These still allow further processing before the program terminates. What else 
> can I try? I am not able to share the exact code at this time. I can provide 
> more detail if I am unclear. Thank you

You could take a look at the Mutiprocessing module capabilities for exchanging 
objects between processes:

http://docs.python.org/3.3/library/multiprocessing.html#exchanging-objects-between-processes
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: multiprocessing: child process race to answer

2013-11-03 Thread Mark Lawrence

On 03/11/2013 10:10, capple...@gmail.com wrote:

On Friday, November 1, 2013 10:35:47 PM UTC-4, smhall05 wrote:

I am using a basic multiprocessing snippet I found:



#-

from multiprocessing import Pool



def  f(x):

 return x*x



if __name__ == '__main__':

 pool = Pool(processes=4)  # start 4 worker processes

 result = pool.apply_async(f, [10])# evaluate "f(10)" asynchronously

 print result.get(timeout=1)

 print pool.map(f, range(10))  # prints "[0, 1, 4,..., 81]"

#-



I am using this code to have each process go off and solve the same problem, 
just with different inputs to the problem. I need to be able to kill all 
processes once 1 of n processes has come up with the solution. There will only 
be one answer.



I have tried:



sys.exit(0) #this causes the program to hang

pool.close()

pool.terminate



These still allow further processing before the program terminates. What else 
can I try? I am not able to share the exact code at this time. I can provide 
more detail if I am unclear. Thank you


You could take a look at the Mutiprocessing module capabilities for exchanging 
objects between processes:

http://docs.python.org/3.3/library/multiprocessing.html#exchanging-objects-between-processes



Would you please read and action this as it prevents the double line 
spacing that you can observe above, thanks 
https://wiki.python.org/moin/GoogleGroupsPython


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: Debugging decorator

2013-11-03 Thread Jason Friedman
> I wrote this decorator: https://gist.github.com/yasar11732/7163528
>
> I ran it with Python 2 and thought it was neat.
Most of my work is Python 3.
I ran 2to3-3.3 against it and I am getting this error:

$ ./simple.py
Traceback (most recent call last):
  File "./simple.py", line 3, in 
@debugger.debugging
  File "/home/jason/python/debugger.py", line 41, in debugging
new_function_body.append(make_print_node("function %s called" %
func.__name__))
  File "/home/jason/python/debugger.py", line 6, in make_print_node
return ast.Print(dest=None, values=[ast.Str(s=s)], nl=True)
AttributeError: 'module' object has no attribute 'Print'

Comparing http://docs.python.org/2/library/ast.html#module-ast against
http://docs.python.org/3.3/library/ast.html#module-ast I see that "Print"
has indeed been removed.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing multiple lines from text file using regex

2013-11-03 Thread Jason Friedman
>  Hi,
> I am having an issue with something that would seem to have an easy
> solution, but which escapes me.  I have configuration files that I would
> like to parse.  The data I am having issue with is a multi-line attribute
> that has the following structure:
>
> banner  
> Banner text
> Banner text
> Banner text
> ...
> 
>
This is an alternative solution someone else posted on this list for a
similar problem I had:

#!/usr/bin/python3
from itertools import groupby
def get_lines_from_file(file_name):
with open(file_name) as reader:
for line in reader.readlines():
yield(line.strip())

counter = 0
def key_func(x):
if x.strip().startswith("banner") and x.strip().endswith(""):
global counter
counter += 1
return counter

for key, group in groupby(get_lines_from_file("my_data"), key_func):
print(list(group)[1:-1])
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-11-03 Thread Antoon Pardon
Op 03-11-13 06:17, Steven D'Aprano schreef:
> On Sat, 02 Nov 2013 18:22:38 +, Joshua Landau wrote:
> [...]
>> Sure, you in all probability didn't mean it like that but rurpy isn't
>> uncalled for in raising the concern. Really I just want to remind you
>> that you're both on the same side here.
> 
> Thanks for the comments Joshua, but I'm afraid I cannot agree. I gave it 
> a lot of thought and I cannot continue to give Rurpy the presumption of 
> good faith any longer. This saddens me, but that's the way it is.
> 
> I'm trying hard to give up threads like this, where people debate the 
> subjective tone of an email and ever more pedantic arguments about the 
> precise wording. Even when all participants are arguing in good faith, 
> they risk becoming quagmires which go nowhere in dozens of posts.

I'm not so sure it is all in good faith. I see a lot of persons digging
in their heels and not much effort in trying to understand someone else's
point of view.

-- 
Antoon Pardon

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


Re: Algorithm that makes maximum compression of completly diffused data.

2013-11-03 Thread Gene Heskett
On Sunday 03 November 2013 04:40:45 Ethan Furman did opine:

> On 10/30/2013 01:32 PM, Gene Heskett wrote:
> > Congratulations Jonas.  My kill file for this list used to have only
> > one name, but now has 2.
> 
> You have more patience than I!  Jonas just made mine seven.  :)
> 
> --
> ~Ethan~

Yeah, well there are a couple others in the mugwump category here yet.  I 
lurk here to try and learn, and baseless arguments are just noise. To be 
filtered.  And its working!

But it may be that this old dog has learned his last "new" trick in the 
language arena too, too many "irons in the fire", and fine tuning machinery 
to run the GCode I write to carve metal or wood is the primary interest 
ATM.  At 79yo, the short term memory needs help.  I'm smart enough to 
understand that, but it doesn't mean I like it.  Its a right PIMA TBE.

Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)

All the evidence concerning the universe has not yet been collected,
so there's still hope.
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
 law-abiding citizens.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-11-03 Thread Antoon Pardon
Op 02-11-13 21:19, Tim Roberts schreef:
> jonas.thornv...@gmail.com wrote:
>>
>> I certainly do not like the old bracket style it was a catastrophe, but 
>> in honesty the gui editor of python should have what i propose, a parser
>> that indent automaticly at loops, functions and end.
> 
> Many editors do that.  Vim, which is what I use, certainly does.
> 
>> I promise you it will save millions of hours of bug searching all over 
>> world in a month.
> 
> I suspect you meant "dozens" rather than "millions"...
> 
> Look, both schemes have their pitfalls.  With an "end" requirement, it's
> easy to have code where the indenting doesn't match the actual nesting, and
> that causes human confusion.

Not really. All examples of this kind of confusion I have seem come from
C where the problem IMO comes from the fact that people can choose to put
one statement after a control structure or a block.

I have programmed sometime in modula2 and this mismatch was just not a
big deal in that language because such a mismatch usualy resulted in
an end missing and the code not compiling, which resolves the confusion
rather quickly.

Now of course I can mis something. Maybe you can provide an example that
would be confusing even with modula2 kind of control structures and still
compile and produce a hard to trace bug.

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


Re: How to add a current string into an already existing list

2013-11-03 Thread Roy Smith
In article ,
 Gregory Ewing  wrote:

> Nick the Gr33k wrote:
> > I just want a mysql column type that can be eligible to store an array 
> > of elements, a list that is, no need for having a seperate extra table 
> > for that if we can have a column that can store a list of values.
> 
> Relational database systems typically don't provide any
> such type, because it's not the recommended way of storing
> that kind of data in a relational database.
> 
> The recommended way is to use a secondary table, as has
> been pointed out.

Most SQL databases allow you to store arbitrary data as an opaque value 
(i.e. BLOB).  So, one possibility would be to just serialize your list 
(pickle, json, whatever) and store it that way.  I've seen databases 
that didn't use BLOB, but just stored json in a string field.

The limitation, of course, is that the data is opaque as far as the 
database goes; you can't do queries against it.  But, if all you need to 
do is store the list and be able to retrieve it, it's a perfectly 
reasonable thing to do, and a lot more efficient than doing a join on a 
secondary table.

Normalization is for database weenies :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-11-03 Thread jonas . thornvall
Den lördagen den 2:e november 2013 kl. 21:19:44 UTC+1 skrev Tim Roberts:
> jonas.thornv...@gmail.com wrote:
> 
> >
> 
> >I certainly do not like the old bracket style it was a catastrophe, but 
> 
> >in honesty the gui editor of python should have what i propose, a parser
> 
> >that indent automaticly at loops, functions and end.
> 
> 
> 
> Many editors do that.  Vim, which is what I use, certainly does.
> 
> 
> 
> >I promise you it will save millions of hours of bug searching all over 
> 
> >world in a month.
> 
> 
> 
> I suspect you meant "dozens" rather than "millions"...
> 
> 
> 
> Look, both schemes have their pitfalls.  With an "end" requirement, it's
> 
> easy to have code where the indenting doesn't match the actual nesting, and
> 
> that causes human confusion.  Without the "end" requirement, it's not hard
> 
> to type code where you forget to dedent.  Those are just two manifestations
> 
> of the exact same problem.  Neither scheme is provably superior to the
> 
> other.  It's just a choice that a language designer has to make.
> 
> 
> 
> I happen to like Python's choice.  You'll get used to it.
> 
> -- 
> 
> Tim Roberts, t...@probo.com
> 
> Providenza & Boekelheide, Inc.

What does Vim stand for Voyager interstellar mission?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-11-03 Thread jonas . thornvall
Den lördagen den 2:e november 2013 kl. 21:19:44 UTC+1 skrev Tim Roberts:
> jonas.thornv...@gmail.com wrote:
> 
> >
> 
> >I certainly do not like the old bracket style it was a catastrophe, but 
> 
> >in honesty the gui editor of python should have what i propose, a parser
> 
> >that indent automaticly at loops, functions and end.
> 
> 
> 
> Many editors do that.  Vim, which is what I use, certainly does.
> 
> 
> 
> >I promise you it will save millions of hours of bug searching all over 
> 
> >world in a month.
> 
> 
> 
> I suspect you meant "dozens" rather than "millions"...
> 
> 
> 
> Look, both schemes have their pitfalls.  With an "end" requirement, it's
> 
> easy to have code where the indenting doesn't match the actual nesting, and
> 
> that causes human confusion.  Without the "end" requirement, it's not hard
> 
> to type code where you forget to dedent.  Those are just two manifestations
> 
> of the exact same problem.  Neither scheme is provably superior to the
> 
> other.  It's just a choice that a language designer has to make.
> 
> 
> 
> I happen to like Python's choice.  You'll get used to it.
> 
> -- 
> 
> Tim Roberts, t...@probo.com
> 
> Providenza & Boekelheide, Inc.

Was there a VIM discussion group?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to add a current string into an already existing list

2013-11-03 Thread Chris Angelico
On Sun, Nov 3, 2013 at 11:16 PM, Roy Smith  wrote:
> The limitation, of course, is that the data is opaque as far as the
> database goes; you can't do queries against it.  But, if all you need to
> do is store the list and be able to retrieve it, it's a perfectly
> reasonable thing to do, and a lot more efficient than doing a join on a
> secondary table.

Yeah, that can be an effective way to store complex data - especially
if the nesting level isn't fixed. (Normalization can handle a
single-level list, but it's a lot messier for handling lists of lists,
for instance.)

I still think that the OP's task would be best suited to a separate
table (one table of visitors, another of downloads, where the
Downloads table has a foreign key to Visitors), but I'm reminded of
XKCD 1027: the thing standing in the way of his code is that the
person coding it... is him. And of course, this is all without getting
into the non-code aspects of this proposal - as have been mentioned
several times, like EU regulations on retaining this level of data.

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


Re: Debugging decorator

2013-11-03 Thread Chris Angelico
On Mon, Nov 4, 2013 at 12:20 AM, Chris Angelico  wrote:
> As print is now a function, you're going to need to construct a
> function call element instead of a special 'print' node. I don't know
> how to do that as I'm not an AST expert, but hopefully you can work it
> out from there?
>
> If you need it to be cross-version, you could probably use
> sys.stdout.write explicitly (not forgetting to add a newline, which
> print does and write - obviously - doesn't). Or just demand that "from
> __future__ import print_function" be used, which will make 2.7 like
> 3.3.

Oh, I just noticed that the person using 2to3 wasn't the OP. My
apologies, my language was aimed at the decorator's primary developer.
Yasar, are you prepared to take on Python 3 support fully? If it's as
simple as tweaking the Print nodes, that shouldn't be too hard (I
hope).

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


Re: Debugging decorator

2013-11-03 Thread Chris Angelico
On Sun, Nov 3, 2013 at 9:55 PM, Jason Friedman  wrote:
>
>> I wrote this decorator: https://gist.github.com/yasar11732/7163528
>>
> I ran it with Python 2 and thought it was neat.
> Most of my work is Python 3.
> I ran 2to3-3.3 against it and I am getting this error:
>
> $ ./simple.py
> Traceback (most recent call last):
>   File "./simple.py", line 3, in 
> @debugger.debugging
>   File "/home/jason/python/debugger.py", line 41, in debugging
> new_function_body.append(make_print_node("function %s called" %
> func.__name__))
>   File "/home/jason/python/debugger.py", line 6, in make_print_node
> return ast.Print(dest=None, values=[ast.Str(s=s)], nl=True)
> AttributeError: 'module' object has no attribute 'Print'
>
> Comparing http://docs.python.org/2/library/ast.html#module-ast against
> http://docs.python.org/3.3/library/ast.html#module-ast I see that "Print"
> has indeed been removed.

Ah, that'd be because 'print' is no longer a statement. Check out this
function's disassembly:

def hello_world():
print("Hello, world!")

Python 2.7:
  2   0 LOAD_CONST   1 ('Hello, world!')
  3 PRINT_ITEM
  4 PRINT_NEWLINE
  5 LOAD_CONST   0 (None)
  8 RETURN_VALUE

Python 3.3:
  2   0 LOAD_GLOBAL  0 (print)
  3 LOAD_CONST   1 ('Hello, world!')
  6 CALL_FUNCTION1 (1 positional, 0 keyword pair)
  9 POP_TOP
 10 LOAD_CONST   0 (None)
 13 RETURN_VALUE

As print is now a function, you're going to need to construct a
function call element instead of a special 'print' node. I don't know
how to do that as I'm not an AST expert, but hopefully you can work it
out from there?

If you need it to be cross-version, you could probably use
sys.stdout.write explicitly (not forgetting to add a newline, which
print does and write - obviously - doesn't). Or just demand that "from
__future__ import print_function" be used, which will make 2.7 like
3.3.

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


Re: Algorithm that makes maximum compression of completly diffused data.

2013-11-03 Thread Michael Torrie
On 11/03/2013 12:09 AM, Mark Janssen wrote:
>>> Congratulations Jonas.  My kill file for this list used to have only one
>>> name, but now has 2.
>>
>> You have more patience than I!  Jonas just made mine seven.  :)
> 
> Gosh, don't kill the guy.  It's not an obvious thing to hardly anyone
> but computer scientists.  It's an easy mistake to make.

I don't think he's being plonked for not understanding computational
theory.  He's being plonked for resorting to name calling on his second
post!  If he was a smart computer scientist type, then engaging in a
discussion about the theoretical aspects of his algorithm would have
been welcomed by him, because that's what science is all about.  But he
failed that early on.

Thanks to everyone in this part of the thread for turning this
ridiculous farce into a really educational discussion on the theory of
information compression.  Too bad the OP has tuned out a long time ago.

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


Re: Algorithm that makes maximum compression of completly diffused data.

2013-11-03 Thread Joshua Landau
On 3 November 2013 03:17, Steven D'Aprano
 wrote:
> On Sat, 02 Nov 2013 14:31:09 -0700, Tim Roberts wrote:
>
>> jonas.thornv...@gmail.com wrote:
>>>
>>>Well then i have news for you.
>>
>> Well, then, why don't you share it?
>>
>> Let me try to get you to understand WHY what you say is impossible.
> [snip reasons]
>
> But your second reason, better known as the pigeonhole principle,
> demonstrates that for any lossless compression method, there must be data
> sets that actually expand the data. It doesn't matter how cleverly you
> compress the data, you can't fit 20kg of potatoes in a 10kg bag, so to
> speak. Suppose your compression algorithm compresses a single byte into a
> nybble (four bits). There are 256 different input data sets (0x00,
> 0x01, ... 0xFF) and only 16 different outputs (0x0, 0x1, ... 0xF). There
> is no way for 256 pigeons to fit in 16 pigeon holes unless you put two or
> more pigeons in at least one hole. Ergo, if the compression algorithm is
> lossless, *some* data must be expanded rather than compressed.

You have to be careful to make this totally rigorous, too.

Note that I *can* make a "compression" algorithm that takes any
length-n sequence and compresses all but one sequence by at least one
bit, and does not ever expand the data.

"00" -> ""
"01" -> "0"
"10" -> "1"
"11" -> "00"

This, obviously, is just 'cause the length is an extra piece of data,
but sometimes you have to store that anyway ;). So if I have a list of
N length-Y lists containing only 1s or 0s, I can genuinely compress
the whole structure by N log2 Y items.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Algorithm that makes maximum compression of completly diffused data.

2013-11-03 Thread Joshua Landau
On 3 November 2013 15:34, Joshua Landau  wrote:
>I can genuinely compress
> the whole structure by N log2 Y items.

By which I mean 2N items.
-- 
https://mail.python.org/mailman/listinfo/python-list


Automation

2013-11-03 Thread Renato Barbosa Pim Pereira
I have one .xls file with the values of PV MV and SP, I wanna to calculate
Kp Ki Kd with python from this file, can anyone give me any suggestion
about how can I do this? From now, thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-11-03 Thread rurpy
On 11/01/2013 09:52 PM, Steven D'Aprano wrote:
>[...]
> I did not declare as a 
> fact that he had no experience, as you claim, but posed it as a question 
> and expressed it explicitly as a subjective observation.

This is a key point.  Several of your other denials are 
true only if you are right about this. 

You concluded your reply to Skybuck with:
 
 "Wait *until* you *start* programming..." [my emphasis]

The implication, that the OP does not have any programming 
experience, will be clear to anyone with with even mediocre 
English speaking ability.  The semantic information conveyed 
to the OP is the same as the statement of fact, "you have no 
programming experience" and it is perfectly valid to claim 
that you told the OP that he had no programming experience.

I pointed this out in nearly every email but in every one 
of your responses to it, you ignore that concluding sentence
and mention *only* your initial questioning sentence to 
justify your assertion that you "posed it as a question".

As an aside, you shouldn't rely on that initial question
sentence so much either -- just because something is framed
as a question does not mean its intent is not to attack:
"excuse me for asking, but are you an asshole?"
You asked, "have you *ever* done *any* programming *at all*?" 
[my emphasis] which could be as easily taken as rhetorically 
laying the ground for discrediting his idea as an honest 
neutral question and the former interpretation is strengthened 
by your concluding "wait until..." statement.

My claims of "ad hominem" and "attack" follow from the fact 
that you *did* tell the OP he had no programming experience, 
in direct contradiction to what he had stated, and with no 
evidence to support your claim beyond the OP's opinions on 
loops and goto's.

> Each time I have responded to you, I have given direct quotes and 
> directly addressed the substance of your posts, which is all to do with 
> the supposed tone of my response to the OP. Each time you have continued 
> to misrepresent me, misquote me, and interpret my words assuming bad 
> faith rather than good, in order to justify your idea that my post was an 
> ad hominem attack.
> 
> Including this post, where you make the false statement that:
> 
> [quote]
> His idea was that loop tests should always or usually be done 
> at the end of the loop.  You discussed *nothing* that supported
> that idea.
> 
> Emphasis yours. But in fact I gave the concrete example of Pascal 
> repeat...until loops, which have the test at the end of the loop. So yet 
> again your claims are simply wrong.

That was an unfortunate example for you to chose since it 
directly contradicts your claims.

Read that quote again.  You are a programmer.  You should 
understand logic.  Please explain how acknowledging *one* 
useful end-of-loop construct supports the idea that 
  /quote/ 
  loop tests should *always or usually* be done at the end of the loop 
  /endquote/,
especially when you present it with long string of cases where 
testing at the bottom is *not* desirable.  You did not agree 
with the OPs idea that the test should *always* go at the end 
of the loop and I represented your opinion as such.

This was pointed out to you before yet you continue to claim
I am misrepresenting you.

> This is four posts in a row now that you have wrongly represented me. I 
> can only conclude that you think that by repeating a lie often enough, 
> you'll convince others that it must be true and "win".

In my preceding post, I pointed out your practice of repeating
the same discredited accusations in the the hope that repeating 
them enough would somehow make them true... It is amusing to 
see you lift my own words to use against me (although I used 
the word "accusation" and you choose to use the word "lie" -- 
a difference in our standards I guess.)

I misrepresented you once, immediately acknowledged and corrected
it when you pointed it out.  You have continued to accuse me of 
misrepresenting you in *every* post you've made, while refusing 
to respond to my request to tell me how you think you *should* be
paraphrased.

Indeed you have followed a consistent policy of falsely accusing 
me of underhanded and disreputable practices, while at the same
time, often in the same sentence, engaging copiously in exactly 
those same practices yourself.  

> I will no longer 
> play this game with you. Goodbye.
> 
> *plonk*
 
Bye.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-11-03 Thread rurpy
On 11/02/2013 11:17 PM, Steven D'Aprano wrote:
> On Sat, 02 Nov 2013 18:22:38 +, Joshua Landau wrote:
> [...]
>> Sure, you in all probability didn't mean it like that but rurpy isn't
>> uncalled for in raising the concern. Really I just want to remind you
>> that you're both on the same side here.
> 
> Thanks for the comments Joshua, but I'm afraid I cannot agree. I gave it 
> a lot of thought and I cannot continue to give Rurpy the presumption of 
> good faith any longer. This saddens me, but that's the way it is.

Steven, "presumption of good faith" is typical of the 
disingenuous remarks that have permeated your posts 
in this thread.

Early on, I misrepresented you by claiming you thought
Skybuck's proposal was "nutty" rather than that you 
simply and reasonably disagreed with it [*1].  I also 
used the phrase "makes no sense" implying it came from 
you rather than from Skybuck as it had [*2].

However in pointing my mistake out [*3], you did so 
with remarks like:

 "You're making that quote up"
 "that you would invent such a bare-faced falsehood
 "that it is the *opposite* of what I actually said
 "I don't know whether you are deliberately lying"
 "you're just such a careless reader" 

As soon as you pointed out my mistake, I immediately 
acknowledged and corrected it [*4].  You continued 
with the outrage and attacks on my character.

Bad faith in my part indeed.  The nice thing about 
email is that there exists a record that anyone can 
refer to if they want to discern the truth.


[*1] https://groups.google.com/d/msg/comp.lang.python/p1E0d1UGeY8/e6Xs56paZSoJ
[*2] https://groups.google.com/d/msg/comp.lang.python/p1E0d1UGeY8/yDJJER6EJiIJ
[*3] https://groups.google.com/d/msg/comp.lang.python/p1E0d1UGeY8/SwMcqPLMwjgJ
[*4] https://groups.google.com/d/msg/comp.lang.python/p1E0d1UGeY8/7fLfIxBG4UUJ
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Basic Python Questions - Oct. 31, 2013

2013-11-03 Thread Jim Gibson
In article , E.D.G.
 wrote:

>My main, complex programs won't be run at Web sites. They will 
> instead continue to be available as downloadable exe programs.  The CGI (or 
> whatever) programming work would involve relatively simple programs. But 
> they would need to be able to generate charts that would be displayed on Web 
> pages. That sounds like it is probably fairly easy to do using Python. A 
> Perl - Gnuplot combination is also supposed to be able to do that. But so 
> far I have not seen any good explanations for how to actually get Gnuplot to 
> run as a callable CGI program. So other programs such as Python are being 
> considered.

One way to generate plot within a CGI program is this:

1. Write a file with gnuplot commands (e.g., 'gnuplot.cmd') that set
the output device to a graphics file of some format (e.g., PNG),
generate a plot, and quit gnuplot.

2. Run gnuplot and point it to the file of commands (e.g., 'gnuplot
gunplot.cmd') . How this is done depends upon the CGI program language
(see below).

3. Generate HTML that uses the generated graphics file as an embedded
image (using the  tag).

I have done this in the past, but not recently. This should work for
Python (os.system("gnuplot gnuplot.cmd") or Perl (system("gnuplot
gnuplot.cmd") with suitable commands to execute external programs.

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


Re: Basic Python Questions - Oct. 31, 2013

2013-11-03 Thread rusi
On Sunday, November 3, 2013 1:13:13 PM UTC+5:30, Steven D'Aprano wrote:
> On Sun, 03 Nov 2013 01:02:24 -0500, E.D.G. wrote:

> [...]
> > Since Perl has a calculation speed
> > limit that is probably not easy to get around, before too long another
> > language will be selected for initially doing certain things such as
> > performing calculations and plotting charts. And the existing Perl code
> > might then be gradually translated into that new language.

> The nice things about Python are that it makes a great glue language for 
> putting together components written in low-level languages like C and 
> Fortran, and that there is a rich ecosystem of products for speeding it
> up in various ways. So when you hit the speed limits of pure Python, you
> have lots of options. In no particular order:

> * try using another Python compiler: PyPy is probably the most 
>   mature of the stand-alone optimizing compilers, and you can 
>   expect to double the speed of "typical" Python code, but 
>   there are others;

> * use numpy and scipy for vectorized mathematical routines;

> * re-write critical code as C or Fortran libraries;

> * use Pyrex (possibly unmaintained now) or Cython to write
>   C extensions in a Python-like language;

> * use Psyco or Numba (JIT specialising compilers for Python);

> * use Theano (optimizing computer algebra system compiler);

> * use ctypes to call C functions directly;

> * use other products like Boost, Weave, and more.

Yes python is really state-of-art in this respect:
Every language will have some area where it sucks.
Allowing for a hatch where one could jump out is helpful.
Python allows more such hatches than probably any other language (that I know)

https://mail.python.org/pipermail/python-list/2012-August/628090.html
is a (non exhaustive) list I had made some time.

On the other hand if you know you are going to be escaping out often,
you may want to consider whether the 'escapee' should be your base
rather than python.

Which means take something like the pairwise function and code it up in python 
and julia -- its hardly 10 lines of code.  And see what comparative performance 
you get. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Basic Python Questions - Oct. 31, 2013

2013-11-03 Thread Mark Lawrence

On 03/11/2013 18:28, rusi wrote:


Which means take something like the pairwise function and code it up in python 
and julia -- its hardly 10 lines of code.  And see what comparative performance 
you get.



Solely on the grounds that you've mentioned julia how about this 
http://blog.leahhanson.us/julia-calling-python-calling-julia.html


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


ANN: rom 0.22 - Redis object mapper for Python

2013-11-03 Thread Josiah Carlson
Hey everyone,

As time progresses, so does my Redis object mapper.

The "rom" package is a Redis object mapper for Python. It sports an
interface similar to Django's ORM, SQLAlchemy + Elixir, or Appengine's
datastore.

The changelog for recent releases can be seen below my signature.

You can find the package at:
https://www.github.com/josiahcarlson/rom
https://pypi.python.org/pypi/rom

And docs can be found at:
http://pythonhosted.org/rom/

Please CC me on any replies if you have any questions or comments.

Thank you,
 - Josiah

#--- 0.22

[fixed] size estimation for intersection ordering when filtering has now
been
fixed, thank you to https://github.com/MickeyKim for the report and the
change (should improve performance).
[fixed] an issue with some types when trying to update attributes has now
been
fixed, thank you to https://github.com/denisvolokh for the report.
[changed] improved performance for simple numeric range queries of the form
Model.get_by(attr=value) or Model.get_by(attr=(min, max)) by roughly a
factor of 60x or better in some cases. Thank you to
https://github.com/MickeyKim for the report on poor performance.
#--- 0.21

[fixed] upload for rom 0.20 was missing new columns.py, now fixed
#--- 0.20

[changed] Added exception when performing .all(), .execute(), or .count() on
query objects that have had no filters or attribute ordering provided.
This addresses issue #12.
[changed] Moved column definitions to their own module, shouldn't affect any
normal uses of rom.
[added] For users of Redis 2.6 and later, there is a beta Lua-enabled
writing
option that allows for multiple unique columns on models. In some cases,
this may improve performance when writing many entities very quickly.
[added] The ability to reload an entity from Redis, optionally discarding
any
modifications to the object itself. Check out the documentation for
Model.refresh(), Session.refresh(), and Session.refresh_all()
[added] Tests for the newly changed/added features.
[changed] Tests no longer use flushdb() - all test models/indexes/etc. are
prefixed with RomTest, and we find/delete such keys before and after any
tests are run. Now anyone can reasonably run the test suite.
#--- 0.19

[fixed] Thanks to a bug report by https://github.com/MickeyKim , was
notified
of a bug when using unique indexes, which is now fixed and has a
testcase.
-- 
https://mail.python.org/mailman/listinfo/python-list


Debugging decorator

2013-11-03 Thread Yaşar Arabacı
I don't think it would be much problem. I can do that when I have spare time.

Yasar.

> Oh, I just noticed that the person using 2to3 wasn't the OP. My
> apologies, my language was aimed at the decorator's primary developer.
> Yasar, are you prepared to take on Python 3 support fully? If it's as
> simple as tweaking the Print nodes, that shouldn't be too hard (I
> hope).

> ChrisA

-- 
http://ysar.net/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: zero argument member functions versus properties

2013-11-03 Thread Peter Cacioppi
Ian said :

" Whereas in Python, an attribute access is just
compiled as an attribute access no matter what the underlying
implementation of that access may end up being at run-time. "

Really? Very nice. Have a good link handy for that? I'm compiling a codex of 
"why py is better?".
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-11-03 Thread Antoon Pardon
Op 03-11-13 06:17, Steven D'Aprano schreef:
> On Sat, 02 Nov 2013 18:22:38 +, Joshua Landau wrote:
> [...]
>> Sure, you in all probability didn't mean it like that but rurpy isn't
>> uncalled for in raising the concern. Really I just want to remind you
>> that you're both on the same side here.
> 
> Thanks for the comments Joshua, but I'm afraid I cannot agree. I gave it 
> a lot of thought and I cannot continue to give Rurpy the presumption of 
> good faith any longer. This saddens me, but that's the way it is.

Why can't you? I think you should give Rurpy more credit. If you want
this to make a welcoming community, then you should take such remarks
seriously. You should realise that you are not in a good position to
evaluate how your words come accross because you rely on the knowledge
of your intentions. Others who don't know your intentions can reasonably
get a very different understanding of what you intended.

> I'm trying hard to give up threads like this, where people debate the 
> subjective tone of an email and ever more pedantic arguments about the 
> precise wording. Even when all participants are arguing in good faith, 
> they risk becoming quagmires which go nowhere in dozens of posts.

So it seems you want this to be a welcoming community, as long as we don't
propose you to change your own behaviour. As soon as it is suggested you may
have to adapt your own behaviour in order to make this a welcoming community,
threads where this sort of things are discusseed in, no longer appeal to
you?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Automation

2013-11-03 Thread bob gailer

On 11/3/2013 11:19 AM, Renato Barbosa Pim Pereira wrote:
I have one .xls file with the values of PV MV and SP, I wanna to 
calculate Kp Ki Kd with python from this file, can anyone give me any 
suggestion about how can I do this?
You could start by explaining what those terms mean. They have no direct 
relationship to Python.


Does this have anything to do with statistics? Quantum theory? Telephony?

P = Pluto, V = Venus, S = Saturn?

Help us understand - then we *might* be able to help you.

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

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


Re: Automation

2013-11-03 Thread renato . barbosa . pim . pereira
http://pastebin.com/N9dgaHTx

With this program I can read a csv file with 3 columns, in one of these columns 
I need to read the value more high and multiply by 0.632 and with result, 
search in the same column by a value that aproximate with this result, and then 
return the vector position.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Automation

2013-11-03 Thread Mark Lawrence

On 03/11/2013 21:22, bob gailer wrote:

On 11/3/2013 11:19 AM, Renato Barbosa Pim Pereira wrote:

I have one .xls file with the values of PV MV and SP, I wanna to
calculate Kp Ki Kd with python from this file, can anyone give me any
suggestion about how can I do this?

You could start by explaining what those terms mean. They have no direct
relationship to Python.

Does this have anything to do with statistics? Quantum theory? Telephony?

P = Pluto, V = Venus, S = Saturn?

Help us understand - then we *might* be able to help you.



According to http://www.acronymfinder.com there are only 85 meanings for 
PV, 75 for MV and a mere 290 for SP so simply take your pick :)


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-11-03 Thread Ben Finney
Antoon Pardon  writes:

> Op 03-11-13 06:17, Steven D'Aprano schreef:
> > I'm trying hard to give up threads like this, where people debate
> > the subjective tone of an email and ever more pedantic arguments
> > about the precise wording. Even when all participants are arguing in
> > good faith, they risk becoming quagmires which go nowhere in dozens
> > of posts.
>
> So it seems you want this to be a welcoming community, as long as we
> don't propose you to change your own behaviour.

We aim to be a community that always welcomes diversity of people. This
does not entail always welcoming bad behaviour.

Steven is aiming to change his behaviour to make the community more
welcoming of people: he is aiming to cease contributing to threads where
the bad behaviour is an interminable discussion of tone and pedantry.
This is, as I see it, wholly compatible with making the community more
welcoming to people, by reducing the volume of such threads.

-- 
 \   Eccles: “I just saw the Earth through the clouds!”  Lew: “Did |
  `\  it look round?”  Eccles: “Yes, but I don't think it saw me.” |
_o__)—The Goon Show, _Wings Over Dagenham_ |
Ben Finney

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


Re: Automation

2013-11-03 Thread Johannes Findeisen
On Sun, 3 Nov 2013 14:19:48 -0200
Renato Barbosa Pim Pereira wrote:

> I have one .xls file with the values of PV MV and SP, I wanna to calculate
> Kp Ki Kd with python from this file, can anyone give me any suggestion
> about how can I do this? From now, thanks.

Did you looked at http://www.python-excel.org/ ?

May this can help you solving your problem.  Since you are not
explaining what you want to do I can really not help you more.  And I
don't use Excel too.

And maybe ask the people over at
http://groups.google.com/group/python-excel if they can help you.

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


Re: Automation

2013-11-03 Thread bob gailer

On 11/3/2013 4:48 PM, renato.barbosa.pim.pere...@gmail.com wrote:

http://pastebin.com/N9dgaHTx

With this program I can read a csv file with 3 columns, in one of these columns 
I need to read the value more high and multiply by 0.632 and with result, 
search in the same column by a value that aproximate with this result, and then 
return the vector position.
Oh ... will you please explain in good English and a lot more detail. I 
can only begin to guess from that what you want. Guessing wastes all our 
time.


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

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


Re: Slicing with negative strides

2013-11-03 Thread Martin Manns
On 29 Oct 2013 05:22:00 GMT
Steven D'Aprano  wrote:

> Does anyone here use slices (or range/xrange) with negative strides
> other than -1?

I have used negative strides for comparing discrete sequences e. g. for
turbulence analysis, and I hope that my code will still run in Python 4.

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


Re: Basic Python Questions - Oct. 31, 2013

2013-11-03 Thread Grant Edwards
On 2013-11-03, Jim Gibson  wrote:
> In article , E.D.G.
> wrote:
>
>>My main, complex programs won't be run at Web sites. They will 
>> instead continue to be available as downloadable exe programs.  The CGI (or 
>> whatever) programming work would involve relatively simple programs. But 
>> they would need to be able to generate charts that would be displayed on Web 
>> pages. That sounds like it is probably fairly easy to do using Python. A 
>> Perl - Gnuplot combination is also supposed to be able to do that. But so 
>> far I have not seen any good explanations for how to actually get Gnuplot to 
>> run as a callable CGI program. So other programs such as Python are being 
>> considered.
>
> One way to generate plot within a CGI program is this:
>
> 1. Write a file with gnuplot commands (e.g., 'gnuplot.cmd') that set
> the output device to a graphics file of some format (e.g., PNG),
> generate a plot, and quit gnuplot.

Or you can use the pygnuplot module which handles much of that for y0ou.

http://pygnuplot.sourceforge.net/

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


Re: Automation

2013-11-03 Thread Denis McMahon
On Sun, 03 Nov 2013 14:19:48 -0200, Renato Barbosa Pim Pereira wrote:

> I have one .xls file with the values of PV MV and SP, I wanna to
> calculate Kp Ki Kd with python from this file, can anyone give me any
> suggestion about how can I do this? From now, thanks.

Why use Python? Why not simply write excel to do the calculations?

Assuming PV, MV and SP are in columns, you simply need to write your 
equations for Kp, Ki and Kd so that they reference the relevant columns, 
and then past them down the whole spreadsheet.

Seems to me like you're using a sledgehammer to shell a peanut.

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


Re: Automation

2013-11-03 Thread MRAB

On 03/11/2013 21:53, Mark Lawrence wrote:

On 03/11/2013 21:22, bob gailer wrote:

On 11/3/2013 11:19 AM, Renato Barbosa Pim Pereira wrote:

I have one .xls file with the values of PV MV and SP, I wanna to
calculate Kp Ki Kd with python from this file, can anyone give me any
suggestion about how can I do this?

You could start by explaining what those terms mean. They have no direct
relationship to Python.

Does this have anything to do with statistics? Quantum theory? Telephony?

P = Pluto, V = Venus, S = Saturn?

Help us understand - then we *might* be able to help you.



According to http://www.acronymfinder.com there are only 85 meanings for
PV, 75 for MV and a mere 290 for SP so simply take your pick :)


If you put all "PV MV SP" into Google you get results about Process
Dynamics/Control. Does that help? :-)

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


Problem installing matplotlib 1.3.1 with Python 2.7.6 and 3.3.3 (release candidate 1)

2013-11-03 Thread Piet van Oostrum
Hello,

I tried to install matplotlib 1.3.1 on the release candidates of Python 2.7.6 
and 3.3.3.
I am on Mac OS X 10.6.8.
Although the installation gave no problems, there is a problem with Tcl/Tk.

The new Pythons have their own embedded Tcl/Tk, but when installing matplotlib 
it links to the Frameworks version of Tcl and TK, not to the embedded version. 
This causes confusion when importing matplotlib.pyplot:

objc[70648]: Class TKApplication is implemented in both 
/Library/Frameworks/Python.framework/Versions/2.7/lib/libtk8.5.dylib and 
/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. 
Which one is undefined.
objc[70648]: Class TKMenu is implemented in both 
/Library/Frameworks/Python.framework/Versions/2.7/lib/libtk8.5.dylib and 
/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. 
Which one is undefined.
objc[70648]: Class TKContentView is implemented in both 
/Library/Frameworks/Python.framework/Versions/2.7/lib/libtk8.5.dylib and 
/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. 
Which one is undefined.
objc[70648]: Class TKWindow is implemented in both 
/Library/Frameworks/Python.framework/Versions/2.7/lib/libtk8.5.dylib and 
/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. 
Which one is undefined.

And then later it gives a lot of error messages.

So I think it should be linked to the embedded version. For this the matplotlib 
setupext.py should be adapted to find out if there is an embedded Tcl/Tk in the 
Python installation and set the link parameters accordingly. However, the 
installed Python versions (from the DMG's) do not contain the Tcl/Tk header 
files, only the shared library and the tcl files. So I thing the distributed 
Python should also include the Tcl/Tk header files.
-- 
Piet van Oostrum 
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Parsing multiple lines from text file using regex

2013-11-03 Thread Marc
>This is an alternative solution someone else posted on this list for a 
> similar problem I had:

 

>#!/usr/bin/python3

>from itertools import groupby

>def get_lines_from_file(file_name):

>with open(file_name) as reader:

>for line in reader.readlines():

>yield(line.strip())

 

>counter = 0

>def key_func(x):

>if x.strip().startswith("banner") and x.strip().endswith(" delimiter>"):

>global counter

>counter += 1

>return counter

 

>for key, group in groupby(get_lines_from_file("my_data"), key_func):

>print(list(group)[1:-1])

 

 

 

Thanks Jason,

 

banner = re.compile(r'banner\s+(\w+)\s+(.+)(.*?)\2', re.DOTALL).findall(lines)

 

worked nicely to get what I needed:

 

outfile.write("Banner type: %s Banner Delimiter: %s\n" % (banner[0][0], 
banner[0][1]))
outfile.write("Banner Text:\n")
outfile.write(banner[0][2])

 

Probably not the prettiest, most concise code, but it gets the job done.

 

Thanks again,

Marc

 

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


Re: Problem installing matplotlib 1.3.1 with Python 2.7.6 and 3.3.3 (release candidate 1)

2013-11-03 Thread Ned Deily
In article <21110.62791.44734.656...@cochabamba.vanoostrum.org>,
 Piet van Oostrum  wrote:
> I tried to install matplotlib 1.3.1 on the release candidates of Python 2.7.6 
> and 3.3.3.

[...]

Please open an issue on the Python bug tracker for the Python component of 
this.

http://bugs.python.org

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

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


Python Practice Problems

2013-11-03 Thread yungwong . seu
Hi, who has some problems to practice using Python?
Thx a lot!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: zero argument member functions versus properties

2013-11-03 Thread Ian Kelly
On Sun, Nov 3, 2013 at 2:23 PM, Peter Cacioppi  wrote:
> Ian said :
>
> " Whereas in Python, an attribute access is just
> compiled as an attribute access no matter what the underlying
> implementation of that access may end up being at run-time. "
>
> Really? Very nice. Have a good link handy for that? I'm compiling a codex of 
> "why py is better?".

Sorry, no, but this fact should be apparent as a consequence of
Python's dynamicism.  Since the compiler generally can't predict what
the types of objects will be, the bytecode that it generates can't
depend on those types.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Algorithm that makes maximum compression of completly diffused data.

2013-11-03 Thread Mark Janssen
> Note that I *can* make a "compression" algorithm that takes any
> length-n sequence and compresses all but one sequence by at least one
> bit, and does not ever expand the data.
>
> "00" -> ""
> "01" -> "0"
> "10" -> "1"
> "11" -> "00"
>
> This, obviously, is just 'cause the length is an extra piece of data,
> but sometimes you have to store that anyway ;).

And how many bits will you use to store the length?

> So if I have a list of
> N length-Y lists containing only 1s or 0s, I can genuinely compress
> the whole structure by N log2 Y items.

But you cheated by using a piece of information from "outside the
system": length.  A generic compression algorithm doesn't have this
information beforehand.
-- 
MarkJ
Tacoma, Washington
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Automation

2013-11-03 Thread bob gailer
Let's remember that it is the job of the OP to explain his problem so we 
can offer solutions.


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

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


Re: Basic Python Questions - Oct. 31, 2013

2013-11-03 Thread rusi
On Monday, November 4, 2013 12:28:24 AM UTC+5:30, Mark Lawrence wrote:
> On 03/11/2013 18:28, rusi wrote:
> > Which means take something like the pairwise function and code it
> > up in python and julia -- its hardly 10 lines of code.  And see
> > what comparative performance you get.

> Solely on the grounds that you've mentioned julia how about this 
> http://blog.leahhanson.us/julia-calling-python-calling-julia.html

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


Re: Automation

2013-11-03 Thread rusi
On Sunday, November 3, 2013 9:49:48 PM UTC+5:30, Renato Barbosa Pim Pereira 
wrote:
> I have one .xls file with the values of PV MV and SP, I wanna to 
> calculate Kp Ki Kd with python from this file, can anyone give me any 
> suggestion about how can I do this? From now, thanks.

You need something like this?

http://stackoverflow.com/questions/5425210/shortcut-to-apply-a-formula-to-an-entire-column-in-excel
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Automation

2013-11-03 Thread Dan Stromberg
On Sun, Nov 3, 2013 at 8:19 AM, Renato Barbosa Pim Pereira <
renato.barbosa.pim.pere...@gmail.com> wrote:

> I have one .xls file with the values of PV MV and SP, I wanna to calculate
> Kp Ki Kd with python from this file, can anyone give me any suggestion
> about how can I do this? From now, thanks.
>

You're being rather vague, so my answer is vague too.  I won't attempt to
deal with the formulas for your conversions - apparently that's your
business.

But for dealing with xls files, I recommend saving to and reading from .csv
files; Python deals great with these.

If you're not concerned about getting (further) locked into a dying,
binary-only platform, you could use xlrd and xlwt though.

It looks like xlrd runs on 2.x and 3.x, while xlwt is still 2.x only -
that's another reason to go with csv, which works well with 2.x and 3.x for
reading and writing.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Practice Problems

2013-11-03 Thread memilanuk

On 11/03/2013 06:06 PM, yungwong@gmail.com wrote:

Hi, who has some problems to practice using Python?
Thx a lot!



http://projecteuler.net/ is always a good bet

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


Re: Problem installing matplotlib 1.3.1 with Python 2.7.6 and 3.3.3 (release candidate 1)

2013-11-03 Thread Georg Brandl
Am 04.11.2013 01:59, schrieb Ned Deily:
> In article <21110.62791.44734.656...@cochabamba.vanoostrum.org>,
>  Piet van Oostrum  wrote:
>> I tried to install matplotlib 1.3.1 on the release candidates of Python 
>> 2.7.6 
>> and 3.3.3.
> 
> [...]
> 
> Please open an issue on the Python bug tracker for the Python component of 
> this.
> 
> http://bugs.python.org

And please mark as release blocker, I think this should go into 3.3.3rc2.

Georg

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