Tuesday, February 16, 2010

comp.lang.python - 25 new messages in 13 topics - digest

comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en

comp.lang.python@googlegroups.com

Today's topics:

* Which mock library do you prefer? - 4 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/a12daa9de8354ff2?hl=en
* plugin / intra process communication system - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/0a210267753919b0?hl=en
* Hubris connects Ruby to Haskell, will there be such a connection between
Python and Haskell? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/5b5a0c768c788353?hl=en
* Interesting talk on Python vs. Ruby and how he would like Python to have
just a bit more syntactic flexibility. - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/9a88c79d4043ba30?hl=en
* Parsing for email addresses - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/3bb4a0aef7be5837?hl=en
* Is there a simple way to find the list index to the max value? - 3 messages,
3 authors
http://groups.google.com/group/comp.lang.python/t/b8456fe748df61e2?hl=en
* The future of "frozen" types as the number of CPU cores increases - 2
messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/7ef75c20d1be370d?hl=en
* listing existing windows services with python - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/a8c444a258aabc30?hl=en
* shelve.open generates (22, 'Invalid argument') Os X 10.5 with Python 2.5 - 2
messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/b415a047f9b8c570?hl=en
* A fix for pylab and TkAgg plotting in SAGE (Mac OS X) - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/6e5fee52c15c9e3b?hl=en
* Wrestling with the Py2exe Install, Win7, Py2.5 - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/11d75d0eb3dbf903?hl=en
* Shipping Executables - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/297a2754b1ad0538?hl=en
* GIL state during import - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/b9ba52627893a79d?hl=en

==============================================================================
TOPIC: Which mock library do you prefer?
http://groups.google.com/group/comp.lang.python/t/a12daa9de8354ff2?hl=en
==============================================================================

== 1 of 4 ==
Date: Tues, Feb 16 2010 9:08 am
From: Lacrima


On Feb 15, 9:56 pm, Phlip <phlip2...@gmail.com> wrote:
> Lacrima wrote:
> > Thanks for your reply! Isn't what you are talking about integration
> > tests? And unit tests should be fully isolated? So even for method
> > 'some_method()' of class A I should mock instance of class A (i.e. to
> > mock 'self') to test 'some_method()'.
>
> "Unit test" is a high-end QA concept. Developers can get the best
> return on "developer tests". They don't bother with aerospace-quality
> isolation between units.
>
> If a TDD test needs to pull in a bunch of modules to pass, that's
> generally a good thing, because they all get indirect testing. If they
> catch a bug, their local tests might not catch it, but the higher
> level tests still have a chance.
>
> (And if your product still needs unit tests, TDD will make them very
> easy for a formal QA team to add.)
>
> However, expensive setup is a design smell. That means if a test case
> requires too many lines of code for its Assemble phase (before its
> Activate and Assert phases), then maybe those lines of code support
> objects that are too coupled, and they need a better design.
>
> Throwing mocks at these objects, instead of decoupling them, will
> "perfume" the design smell, instead of curing it.
>
> > > "construction encapsulation")
> > And could you give an example.
>
>   def test_frob(self):
>       frob = Frob()
>       frob.knob = Mock()
>       frob.knob.value = Mock(return_value = 42)
>       assert 42 == frob.method_using_knob()
>
> We need the mock because we can't control how Frob's constructor built
> its knob. So instead, give Frob the option to construct with a Knob:
>
>   def test_frob(self):
>       knob = Knob(42)
>       frob = Frob(knob)
>       assert frob.method_using_knob()
>
> Note that in production the Knob constructor never takes a Knob. Maybe
> we should upgrade the production code too (!), or maybe Knob's
> constructor should only create a knob if it didn't get passed one.
> Either technique is acceptable, because the resulting code decouples
> Frobs and Knobs just a little bit more.
>
> > For me it's really hard to develop test first. Often I don't know what
> > tests to write to replace hardcoded return values by objects that
> > perform actual work.
>
> You have read too many books on TDD. C-:
>
> Alternate between writing lines of test and lines of code. Run the
> tests after the fewest possible edits, and always correctly predict if
> the tests will pass, or will fail, and with what diagnostic. (And
> configure your editor to run the stankin tests, no matter how hard it
> fights you!) The high-end tricks will get easier after you get the
> basic cycle down.
>
> --
>   Phlip
>  http://c2.com/cgi/wiki?ZeekLand

Hi Phlip!

Thanks for your exhaustive answer.
Actually, I'll investigate your example with 'frob'. From just reading
the example it's not clear for me what I will benefit, using this
approach.
And I have already refused to write totally isolated tests, because it
looks like a great waste of time.


== 2 of 4 ==
Date: Tues, Feb 16 2010 9:38 am
From: Phlip


On Feb 16, 9:08 am, Lacrima <lacrima.ma...@gmail.com> wrote:

> Thanks for your exhaustive answer.
> Actually, I'll investigate your example with 'frob'. From just reading
> the example it's not clear for me what I will benefit, using this
> approach.

I can't get a good hit for "construction encapsulation" in Google.
(Although I got some good bad ones!)

This paper _almost_ gets the idea:
http://www.netobjectives.com/download/Code%20Qualities%20and%20Practices.pdf

> And I have already refused to write totally isolated tests, because it
> looks like a great waste of time.

Do you run your tests after the fewest possible edits? Such as 1-3
lines of code?

I'm not sure why the TDD books don't hammer that point down...

--
Phlip
http://c2.com/cgi/wiki?ZeekLand


== 3 of 4 ==
Date: Tues, Feb 16 2010 12:30 pm
From: Ben Finney


Lacrima <lacrima.maxim@gmail.com> writes:

> And I have already refused to write totally isolated tests, because it
> looks like a great waste of time.

It only looks like that until you chase your tail in a long, fruitless
debugging session because (you later realise) the behaviour of one test
is being affected by another. Test isolation is essential to ensure that
your tests are doing what you think they're doing.

--
\ "A 'No' uttered from deepest conviction is better and greater |
`\ than a 'Yes' merely uttered to please, or what is worse, to |
_o__) avoid trouble." —Mohandas K. Gandhi |
Ben Finney


== 4 of 4 ==
Date: Tues, Feb 16 2010 2:50 pm
From: Phlip


On Feb 16, 12:30 pm, Ben Finney <ben+pyt...@benfinney.id.au> wrote:
> Lacrima <lacrima.ma...@gmail.com> writes:

> > And I have already refused to write totally isolated tests, because it
> > looks like a great waste of time.
>
> It only looks like that until you chase your tail in a long, fruitless
> debugging session because (you later realise) the behaviour of one test
> is being affected by another. Test isolation is essential to ensure that
> your tests are doing what you think they're doing.

That is runtime test isolation. It's not the same thing as "unit test
isolation". Just take care in your tearDown() to scrub your
environment.

Google "Mock abuse" from here...

--
Phlip

==============================================================================
TOPIC: plugin / intra process communication system
http://groups.google.com/group/comp.lang.python/t/0a210267753919b0?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Feb 16 2010 10:20 am
From: "Diez B. Roggisch"


Am 15.02.10 23:12, schrieb Florian Ludwig:
> On Sun, 2010-02-14 at 18:47 +0100, Diez B. Roggisch wrote:
>>> Here there problem with the trac (and other plugin systems I've
>> seen)
>>> approach:
>>>
>>> You need to define something like:
>>> |
>>> | class IAuthPlugin(Interface): [...]
>>> |
>>> in your blog software.
>>
>> Why? Any reason you can't define it in a separate package the
>> blog-software depends on, as well as your wiki?
>
> That's actually my point - most plugin systems I've seen, like the one
> trac uses, are not encouraging you to do so. Having a module that just
> defines an Interface is kind of weird - and in the real world no one is
> doing it.

Just because nobody doesn't do it doesn't mean it's not desirable. IMHO
the ones using interfaces usually immediatly implement them for some
cases - so you actually get the interface for you authentication
framework, and also implement an OpenID plugin for it. And this forms
one package. Then you can add new packages that implement other things.

repoze.who and what are examples for such design.


>
>> And then of course, this is not really needed. In Python, behavior
>> counts, not type-information. So you can get away without any explicit
>> declared interface. You might chose to not do that, for aestetic
>> reasons, or better documentation. But you aren't forced.
>
> Actually some plugin-systems in python do force you and they check if
> your "implementation" comply with the "interface".

I didn't say nobody does it, I just said it isn't needed to get a
working plugin system. If you don't want to have a separate package
*and* don't want to pull in any unused code, this is pretty much your
only option.

> Here is one solution I came up with. Based on the earlier example:
>>> Lets say you program a wiki and like to allow different kind of
>>> authentications. So you create two plugins (for example one for
>>> OpenID and one for Shibboleth).
>>>
>>> Some time later you feel like reinventing the wheel again and
>>> you program a blog. Again you like to allow different ways of
>>> authentication and you already wrote plugins for exactly the
>>> same for your wiki, right?
>
> auth_openid.py - providing the authentication service
> http://dpaste.com/hold/159619/
>
> wiki.py - providing the wiki
> http://dpaste.com/hold/159634/
>
> Now putting both together:
>
>> import pbus
>>
>> import wiki
>> import auth_openid
>> # or: import auth_shibboleth
>>
>> pbus.get("wiki").run()
>
> No interface definitions.
>
>
> What do you think? Any obvious pitfalls (besides reinventing something)?

I don't know what pbus is supposed to do. Nor how it's laid out on a
python package level.

Diez


== 2 of 2 ==
Date: Tues, Feb 16 2010 11:50 am
From: Florian Ludwig


On Tue, 2010-02-16 at 16:14 +0100, Paul Kölle wrote:
> Am 15.02.2010 23:12, schrieb Florian Ludwig:
> > On Sun, 2010-02-14 at 18:47 +0100, Diez B. Roggisch wrote:
> >> [...]
> >> And then of course, this is not really needed. In Python, behavior
> >> counts, not type-information. So you can get away without any
> >> explicit
> >> declared interface. You might chose to not do that, for aestetic
> >> reasons, or better documentation. But you aren't forced.
> >
> > Actually some plugin-systems in python do force you and they check
> > if your "implementation" comply with the "interface".

> Which is a good thing IMO ;)

Type checking might be good but not pythonic - imo. The problem with
having interfaces needed to be declared (and therefore the possibility
to check) is as I outlined in my first mail:
Where to put those interface descriptions if you want both sides
pluggable? You probably end up depending on other modules/projects just
to import the interfaces.

> > Here is one solution I came up with.
> [...]
> Can you post working code? It's not clear what "pbus" is and how it
> works.

Oh, sorry. The idea is similar to "d-bus" - hence the name. Its "the
communcation system". The code is pretty simple and quick. Please
remember its just to show of the concept not to use it in any production
software or anything.

Instead of using classes as connecting-piece I thought using strings
(maybe path "/plugin/wiki" or "org.example.wiki") might solve my
problem. It might be possible to add optional interface validation
though.


pbus.py - just a simple concept implementation of a framework
http://dpaste.com/hold/159980/

auth_openid.py - providing the authentication service
http://dpaste.com/hold/159619/

wiki.py - providing the wiki
http://dpaste.com/hold/159634/

Now putting both together:

> import pbus
>
> import wiki
> import auth_openid
> # or: import auth_shibboleth
>
> pbus.get("wiki").run()

--
Florian Ludwig <dino@phidev.org>

==============================================================================
TOPIC: Hubris connects Ruby to Haskell, will there be such a connection
between Python and Haskell?
http://groups.google.com/group/comp.lang.python/t/5b5a0c768c788353?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Feb 16 2010 10:32 am
From: Casey Hawthorne


Hubris connects Ruby to Haskell, will there be such a connection
between Python and Haskell?
--
Regards,
Casey


== 2 of 2 ==
Date: Tues, Feb 16 2010 1:12 pm
From: geremy condra


Ok, I'll admit- my hand hovered over the 'initiate flamewar' button
for a moment before
I figured out what you were actually asking.

And I know I'm working on it, which probably means 8 or 9 others are as well.

Geremy Condra

==============================================================================
TOPIC: Interesting talk on Python vs. Ruby and how he would like Python to
have just a bit more syntactic flexibility.
http://groups.google.com/group/comp.lang.python/t/9a88c79d4043ba30?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Feb 16 2010 10:38 am
From: Casey Hawthorne


Interesting talk on Python vs. Ruby and how he would like Python to
have just a bit more syntactic flexibility.

http://blog.extracheese.org/2010/02/python-vs-ruby-a-battle-to-the-death.html
--
Regards,
Casey


== 2 of 2 ==
Date: Tues, Feb 16 2010 11:41 am
From: Andrej Mitrovic


On Feb 16, 7:38 pm, Casey Hawthorne <caseyhHAMMER_T...@istar.ca>
wrote:
> Interesting talk on Python vs. Ruby and how he would like Python to
> have just a bit more syntactic flexibility.
>
> http://blog.extracheese.org/2010/02/python-vs-ruby-a-battle-to-the-de...
> --
> Regards,
> Casey

Gary's friend Geoffrey Grosenbach says in his blog post (which Gary
linked to): "Python has no comparable equivalent to Ruby's do end
block. Python lambdas are limited to one line and can't contain
statements (for, if, def, etc.). Which leaves me wondering, what's the
point?"

I'm sorry, lambda's do support if's and for's. Also, lambda's are
expressions, not statements, but you can pass them around, keep them
in a dictionary if you want to. And if you need more than one line of
statements, for crying out loud use a def? And who needs those "do-
end" blocks anyway, trying to turn Python into Pascal?

==============================================================================
TOPIC: Parsing for email addresses
http://groups.google.com/group/comp.lang.python/t/3bb4a0aef7be5837?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Feb 16 2010 10:58 am
From: galileo228


Hey all, thanks as always for the quick responses.

I actually found a very simple way to do what I needed to do. In
short, I needed to take an email which had a large number of addresses
in the 'to' field, and place just the identifiers (everything to the
left of @domain.com), in a python list.

I simply highlighted all the addresses and placed them in a text file
called emails.txt. Then I had the following code which placed each
line in the file into the list 'names':

[code]
fileHandle = open('/Users/Matt/Documents/python/results.txt','r')
names = fileHandle.readlines()
[/code]

Now, the 'names' list has values looking like this: ['aaa12@domain.com
\n', 'bbb34@domain.com\n', etc]. So I ran the following code:

[code]
for x in names:
st_list.append(x.replace('@domain.com\n',''))
[/code]

And that did the trick! 'Names' now has ['aaa12', 'bbb34', etc].

Obviously this only worked because all of the domain names were the
same. If they were not then based on your comments and my own
research, I would've had to use regex and the split(), which looked
massively complicated to learn.

Thanks all.

Matt

On Feb 15, 8:01 pm, Ben Finney <ben+pyt...@benfinney.id.au> wrote:
> galileo228 <mattbar...@gmail.com> writes:
> > I'm trying to write python code that will open a textfile and find the
> > email addresses inside it. I then want the code to take just the
> > characters to the left of the "@" symbol, and place them in a list.
>
> Email addresses can have more than one '@' character. In fact, the
> quoting rules allow the local-part to contain *any ASCII character* and
> remain valid.
>
> > Any suggestions would be much appeciated!
>
> For a brief but thorough treatment of parsing email addresses, see RFC
> 3696, "Application Techniques for Checking and Transformation of Names"
> <URL:http://www.ietf.org/rfc/rfc3696.txt>, specifically section 3.
>
> --
>  \          "What I have to do is see, at any rate, that I do not lend |
>   `\      myself to the wrong which I condemn." —Henry Thoreau, _Civil |
> _o__)                                                    Disobedience_ |
> Ben Finney

== 2 of 2 ==
Date: Tues, Feb 16 2010 12:15 pm
From: Tim Chase


galileo228 wrote:
> [code]
> fileHandle = open('/Users/Matt/Documents/python/results.txt','r')
> names = fileHandle.readlines()
> [/code]
>
> Now, the 'names' list has values looking like this: ['aaa12@domain.com
> \n', 'bbb34@domain.com\n', etc]. So I ran the following code:
>
> [code]
> for x in names:
> st_list.append(x.replace('@domain.com\n',''))
> [/code]
>
> And that did the trick! 'Names' now has ['aaa12', 'bbb34', etc].
>
> Obviously this only worked because all of the domain names were the
> same. If they were not then based on your comments and my own
> research, I would've had to use regex and the split(), which looked
> massively complicated to learn.

The complexities stemmed from several factors that, with more
details, could have made the solutions less daunting:

(a) you mentioned "finding" the email addresses -- this makes
it sound like there's other junk in the file that has to be
sifted through to find "things that look like an email address".
If the sole content of the file is lines containing only email
addresses, then "find the email address" is a bit like [1]

(b) you omitted the detail that the domains are all the same.
Even if they're not the same, (a) reduces the problem to a much
easier task:

s = set()
for line in file('results.txt'):
s.add(line.rsplit('@', 1)[0].lower())
print s

If it was previously a CSV or tab-delimited file, Python offers
batteries-included processing to make it easy:

import csv
f = file('results.txt', 'rb')
r = csv.DictReader(f) # CSV
# r = csv.DictReader(f, delimiter='\t') # tab delim
s = set()
for row in r:
s.add(row['Email'].lower())
f.close()

or even

f = file(...)
r = csv.DictReader(...)
s = set(row['Email'].lower() for row in r)
f.close()

Hope this gives you more ideas to work with.

-tkc

[1]
http://jacksmix.files.wordpress.com/2007/05/findx.jpg


==============================================================================
TOPIC: Is there a simple way to find the list index to the max value?
http://groups.google.com/group/comp.lang.python/t/b8456fe748df61e2?hl=en
==============================================================================

== 1 of 3 ==
Date: Tues, Feb 16 2010 11:44 am
From: aahz@pythoncraft.com (Aahz)


In article <4B7A91B1.6030301@lonetwin.net>, steve <steve@lonetwin.net> wrote:
>On 02/16/2010 05:49 PM, W. eWatson wrote:
>>
>> See Subject. a = [1,4,9,3]. Find max, 9, then index to it, 2.
>
>The most obvious would be a.index(max(a)). Is that what you wanted ?

The disadvantage of that is that it's O(2N) instead of O(N).
--
Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/

"At Resolver we've found it useful to short-circuit any doubt and just
refer to comments in code as 'lies'. :-)"


== 2 of 3 ==
Date: Tues, Feb 16 2010 11:53 am
From: Tim Golden


On 16/02/2010 19:44, Aahz wrote:
> In article<4B7A91B1.6030301@lonetwin.net>, steve<steve@lonetwin.net> wrote:
>> On 02/16/2010 05:49 PM, W. eWatson wrote:
>>>
>>> See Subject. a = [1,4,9,3]. Find max, 9, then index to it, 2.
>>
>> The most obvious would be a.index(max(a)). Is that what you wanted ?
>
> The disadvantage of that is that it's O(2N) instead of O(N).

<Tongue-in-cheek> Well you could do this:

a.sort ()
return -1

TJG


== 3 of 3 ==
Date: Tues, Feb 16 2010 2:21 pm
From: Arnaud Delobelle


aahz@pythoncraft.com (Aahz) writes:

> In article <4B7A91B1.6030301@lonetwin.net>, steve <steve@lonetwin.net> wrote:
>>On 02/16/2010 05:49 PM, W. eWatson wrote:
>>>
>>> See Subject. a = [1,4,9,3]. Find max, 9, then index to it, 2.
>>
>>The most obvious would be a.index(max(a)). Is that what you wanted ?
>
> The disadvantage of that is that it's O(2N) instead of O(N).

:-)

Joke aside, even though you traverse the list twice, it may still be
quicker than other solutions because both max and list.index are C
functions and no intermediate object is constructed.

--
Arnaud

==============================================================================
TOPIC: The future of "frozen" types as the number of CPU cores increases
http://groups.google.com/group/comp.lang.python/t/7ef75c20d1be370d?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Feb 16 2010 12:15 pm
From: John Nagle


In the beginning, Python had some types which were "frozen", and some which
weren't. Now, there's a trend towards having both "frozen" and "unfrozen"
versions of built-in types. We now have "frozen" and "unfrozen" sets,
dictionaries, and byte arrays. It's becoming clear that that the concept of
"frozen" is separate from the type involved.

Maybe "frozen" should be generalized, so that all "unfrozen" objects also
have "frozen" versions.

I'd suggest

p = freeze(q)

which would generate a "frozen" copy of q. (For lists, this would
return a tuple. For unfrozen sets, a frozen set. Etc.)

p = deepfreeze(q)

would generate "frozen" deep copy of q, for which each object it references
is also a "frozen" copy.

For objects,

class c(frozenobject) :
def __init__(self, someparam) :
self.p = someparam
...

would result in a class which returns frozen objects from the constructor.

In concurrent programs, frozen objects can be shared without locking.
This simplifies locking considerably. This may provide a way to get out
from the Global Interpreter Lock. One possible implementation would be
to have unfrozen objects managed by reference counting and locking as
in CPython. Frozen objects would live in a different memory space and be
garbage collected by a concurrent garbage collector.

If we add "synchronized" objects with built-in locking, like Java,
threading becomes much cleaner.

class d(synchronized) :
...

A typical "synchronized" object would be a queue. Anything with
state shared across threads has to be synchronized. Only one
thread at a time can be active within a synchronized object,
due to a built-in implicit lock.

Semantics of synchronized objects:

"Synchronized" objects cannot be frozen. Trying to freeze
them just returns the object.

If a thread blocks on an explicit "wait", the synchronized
object is temporarily unlocked during the "wait". This
allows threads to wait for, say, a queue to get another
entry from another thread.

If only synchronized objects and frozen objects can be shared across
threads, the GIL becomes unnecessary. Big performance win on multicore
CPUs.

"Synchronized" was a pain in Java because Java doesn't have "frozen"
objects. Too much effort went into synchronizing little stuff. But
in a language with frozen objects, the little stuff would be frozen,
and wouldn't need its own locks.

Threaded programs that already use queue objects to communicate with
each other are almost ready for this kind of architecture now. If
the queue class made a frozen copy of any unfrozen, unsynchronized
copy placed on a queue, conversion to this approach could be almost
automatic.

What would probably happen in practice is that potential race conditions in
existing programs would raise "unshareable object" exceptions,
indicating that something needed to be synchronized. That's a good thing.
This approach makes threading much easier for the typical programmer.
Instead of race conditions and random errors, you get error messages.

And we get rid of the GIL.

I look at this as Python's answer to multicore CPUs and "Go".

John Nagle


== 2 of 2 ==
Date: Tues, Feb 16 2010 2:57 pm
From: Terry Reedy


On 2/16/2010 3:15 PM, John Nagle wrote:
> In the beginning, Python had some types which were "frozen",
> and some which weren't.

In the beginning, there was only one 'frozen' general purpose collection
type, the tuple. And Guido resisted the suggestion that lists and tuple
were mutable and frozen versions of each other.

However, things have changed, and lists and tuple *are* effectively
mutable and hashable versions of each other, and we have the three other
pairs you mentioned. The idea of freeze() may have been floated (and
punctured) during Py3 discussions, but I think it a fairly good one.

Terry Jan Reedy


==============================================================================
TOPIC: listing existing windows services with python
http://groups.google.com/group/comp.lang.python/t/a8c444a258aabc30?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Feb 16 2010 12:15 pm
From: "Alf P. Steinbach"


* Steve Holden:
> Alf P. Steinbach wrote:
> [...]
>>> I'll do some further research to see what's going on there.
>> Cheers,
>>
>> - Alf (is this off-topic for the group?)
>
> It's gone a lot further off than this without anyone complaining. I
> think your experiences to date should convince you that you can rely on
> being told when you drift too far off-topic :)

Some old folks' music, Eternity's Breath & Stratus; the guy playing is 65:

<url: http://www.youtube.com/watch?v=nMH6WH9gyCc>

Hip hoppers may skip the 80 seconds complicated intro.

It is relevant in a way, although very indirectly. For although the comment did
not pop up here, many Satch videos (this is not Satch) have comments like "How
on Earth can he remember all those notes?"

And he doesn't.

It's not memorization: one can't create at this level by memorizing notes or rules.

It's an understanding of the tool one uses and what one wants to create and the
basic themes, and in this video it's also the synergy effect of four people
doing that, creating together something they can't quite believe they're doing,
so you have four madly grinning world class musicians -- and audience... :-)


- Alf

==============================================================================
TOPIC: shelve.open generates (22, 'Invalid argument') Os X 10.5 with Python 2.
5
http://groups.google.com/group/comp.lang.python/t/b415a047f9b8c570?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Feb 16 2010 12:26 pm
From: Ned Deily


In article
<7a9d26a8-0a9f-4bf3-bf50-0ac5e337f482@r24g2000yqd.googlegroups.com>,
seth <hklasky@gmail.com> wrote:
> We have a code that creates a simple Python shelve database. We are
> able to serialize objects and store them in the dbm file. This seem to
> work the same on Windows XP Python 2.5, Ubuntu 9.1 with Python 2.6,
> but on Os X 10.5 with Python 2.5 the database filename is changed by
> the operating system by attaching the .db extension to it. Does an one
> know why is that?

It's a documented "feature": it depends on the underlying database
package used by shelve.

http://docs.python.org/library/shelve.html

"As a side-effect, an extension may be added to the filename ..."

--
Ned Deily,
nad@acm.org

== 2 of 2 ==
Date: Tues, Feb 16 2010 2:03 pm
From: seth


On Feb 14, 1:21 pm, a...@pythoncraft.com (Aahz) wrote:

> Nope -- any reason you can't change the filename?
> --

Os X 10.5 did not recognized the dbm extension.

But, I have been able to fix the problem (hope it helps somebody):
At http://docs.python.org/library/shelve.html it says:

"shelve.open(filename[, flag='c'[, protocol=None[,
writeback=False]]])¶

Open a persistent dictionary. The filename specified is the base
filename for the underlying database. As a side-effect, an extension
may be added to the filename and more than one file may be created. By
default, the underlying database file is opened for reading and
writing. "

Then, I went ahead and try to find out which type of db file was being
created:

print whichdb.whichdb(dbmFile)#prints bsddb185
kpfmac:xLPR kpf$ python
Python 2.5.1 (r251:54863, Feb 9 2009, 18:49:36)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import bsddb185
>>> bsddb185.open('realizations.db')
<bsddb.bsddb object at 0x12260>

I found that the dbm extension is generated by bsddb and bsddb3 so I
went ahead and installed it: sudo easy_install bsddb3.
Finally, in our code, I just went ahead and instead of using
shelve.open, I am calling shelve.BsdDbShelf(bsddb3.btopen(filename,
'c'))

#realizations=shelve.open( filename, 'c', 2, writeback =
False )
#hk 021010: need to use BsdDbShelf to ensure the usage of
bsddb3 on OsX 10.5
#shelve.open creates a bsddb185 file on OsX 10.5
#but shelve.open on OsX reads with bsddb3, who knows why...
#as a result the shelve.open throws
#<class 'bsddb.error'> (22, 'Invalid argument')
dbshelf=shelve.BsdDbShelf(bsddb3.btopen(filename, 'c'))
realizations=dbshelf

And that fixed on Os X 10.5. It also works fine on Windows, by
ensuring the proper import:
try:
import bsddb3
except:
import bsddb as bsddb3

==============================================================================
TOPIC: A fix for pylab and TkAgg plotting in SAGE (Mac OS X)
http://groups.google.com/group/comp.lang.python/t/6e5fee52c15c9e3b?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Feb 16 2010 12:31 pm
From: Lou Pecora


A few weeks ago I posted a problem with Mac OS X with matplotlib in the
SAGE distribution in which attempting to import pylab gave an error
message which stated that there was an import error and the module
_tkagg could not be found. The problem appears to be with matplotlib
(I'm not clear about this). After much searching and some emailing I
have found a solution to this problem and it is easy to do.

Full credit goes to Eric Sonnendrucker who sent it to me.

Here it is:

1) Download the Tcl/Tk sources (go to http://www.tcl.tk/, click on Get
Tcl/Tk Now, click on Sources Download Page,, download the latest
version).

2) In the Terminal cd to the unix folder in the tcl folder. Compile the
unix version (of Tcl and Tk) as follows
./configure --enable-framework --disable-xft
make
make install

3) Install SAGE from source. Download the SAGE source code (go to
http://www.sagemath.org/, click on Download, click on Download complete
source code). In the terminal cd to the SAGE folder and *before* you
run the sage install you need to set

SAGE_MATPLOTLIB_GUI=True

using export SAGE_MATPLOTLIB_GUI=True with bash. The installer then
picks it up automatically.

Complete the SAGE installation by typing make and hit return. That's it.
This will take a while (up to a few hours depending on the computer).

4) You might also need to modify you matplotlibrc by setting
backend='TkAgg' after the installation


Test this by doing an import pylab in sage. You should not get an error.

--
-- Lou Pecora

==============================================================================
TOPIC: Wrestling with the Py2exe Install, Win7, Py2.5
http://groups.google.com/group/comp.lang.python/t/11d75d0eb3dbf903?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Feb 16 2010 1:23 pm
From: "W. eWatson"


I've finally decided to see if I could make an executable out of a py
file. Win7. Py2.5. I brought down the install file and proceeded with
the install. I got two warning messages. Forgot the first. The second
said,"Could not set the key value." I again used OK. I think that was
the only choice. It then issued a message in a larger dialog. It was
about setting a key, and pointed me to a log. It mentions a Removepy2exe -u

Although it finished, I have no idea where the program is. It does not
show up on the Start menu All Programs List nore my desktop. What's up?

I've had these messages (key) occur on other Python installs as I
transition to Win7. So far no problem.


==============================================================================
TOPIC: Shipping Executables
http://groups.google.com/group/comp.lang.python/t/297a2754b1ad0538?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Feb 16 2010 1:41 pm
From: rodmc


Hi,

I have been merrily programming away in Python now for a few years and
have a couple of applications I would like to possibly publish at some
point - with the exception of certain libraries they are more or less
100% Python. However I have read elsewhere online that Python due to
it's architecture is not so good for this, especially as it is easier
for people to hack into the code. Also where software requires some
security aspects I guess it would also not be much use, is this
correct?

Anyway I would appreciate any views or tips that people have?

Kind regards,

rod


== 2 of 2 ==
Date: Tues, Feb 16 2010 2:25 pm
From: geremy condra


On Tue, Feb 16, 2010 at 4:41 PM, rodmc <userprogoogle-139@yahoo.co.uk> wrote:
> Hi,
>
> I have been merrily programming away in Python now for a few years and
> have a couple of applications I would like to possibly publish at some
> point - with the exception of certain libraries they are more or less
> 100% Python. However I have read elsewhere online that Python due to
> it's architecture is not so good for this, especially as it is easier
> for people to hack into the code.

If you mean that it is difficult to stop people from modifying the
source code, then you're correct. If you mean that python
programs are more likely to have security problems than, say,
C, I think its safe to assume that you're not correct about that.

> Also where software requires some
> security aspects I guess it would also not be much use, is this
> correct?

I've never had any reason to feel more concerned about the
code that I write in python, and I use it for crypto research.

> Anyway I would appreciate any views or tips that people have?

I'd worry about developing a product worth stealing before I
worried about people stealing it ;)

Geremy Condra

==============================================================================
TOPIC: GIL state during import
http://groups.google.com/group/comp.lang.python/t/b9ba52627893a79d?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Feb 16 2010 3:01 pm
From: Terry Reedy


On 2/16/2010 4:37 PM, Doron Tal wrote:
> Is the GIL released during import statement execution when accessing the
> file?
> If not, is it a bug?
> If it is not a bug, or it is here to stay for any other reason, I think
> it should be mentioned in the documentation.

The CPython GIL is a CPython implementation artifact and should not be
mentioned in the language docs (and is not, as far as I know). Were you
thinking of something else? And why this specific feature of its
behavior, whatever it is.

tjr

==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.python"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.python?hl=en

To unsubscribe from this group, send email to comp.lang.python+unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.python/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate