comp.lang.python - 25 new messages in 18 topics - digest
comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en
comp.lang.python@googlegroups.com
Today's topics:
* Pycrypto RSA Issue - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/9c5587fe42575deb?hl=en
* Executing Commands From Windows Service - 2 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/9f541d309af57595?hl=en
* Hurry Up, Free Check Of $327 With Your Name. - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/261e8c7f9fe25ec7?hl=en
* Ternary plus - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/05afedbd6dc66a2c?hl=en
* To (monkey)patch or not to (monkey)patch, that is the question - 1 messages,
1 author
http://groups.google.com/group/comp.lang.python/t/49c9d1124ead9150?hl=en
* Modifying Class Object - 4 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/fd36962c4970ac48?hl=en
* Tangling with mathplotlib(MPL) on XP and Win7 -- show() stopper - 1 messages,
1 author
http://groups.google.com/group/comp.lang.python/t/84b2f3125d4d3ab6?hl=en
* errno 107 socket.recv issue - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/ff1ce95292f1a5ec?hl=en
* New to Python - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/429d23f88afefef6?hl=en
* How to measure elapsed time under Windows? - 3 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/340c476d0357a7bd?hl=en
* Python-URL! - weekly Python news and links (Feb 9) - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/0e861974ce5d2b5f?hl=en
* Python and Ruby - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/dfe4f6c60032755e?hl=en
* shelve.open generates (22, 'Invalid argument') Os X 10.5 with Python 2.5 - 1
messages, 1 author
http://groups.google.com/group/comp.lang.python/t/b415a047f9b8c570?hl=en
* PostgreSQL driver for Python applications that supports bytea correctly? - 1
messages, 1 author
http://groups.google.com/group/comp.lang.python/t/70a061b40f4c8cc7?hl=en
* Programing family - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/9c369186368028ed?hl=en
* Problem Regarding Queue - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/74b045cda204e5ee?hl=en
* ANN: obfuscate - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/6374e775e474ee1a?hl=en
* equivalent of Ruby's Pathname? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/f580fb3763208425?hl=en
==============================================================================
TOPIC: Pycrypto RSA Issue
http://groups.google.com/group/comp.lang.python/t/9c5587fe42575deb?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 11:14 am
From: Jordan Apgar
On Feb 9, 1:27 pm, Legrandin <pheenso...@farifluset.mailexpire.com>
wrote:
> > gkey = RSA.generate(384, Random.new().read)
> > string = str((gkey.publickey().__getstate__(),(333,444)))
>
> You are encrypting with RSA a piece of data which is way
> larger than the key size (48 bytes).
ah thanks Legrandin
==============================================================================
TOPIC: Executing Commands From Windows Service
http://groups.google.com/group/comp.lang.python/t/9f541d309af57595?hl=en
==============================================================================
== 1 of 2 ==
Date: Tues, Feb 9 2010 11:18 am
From: David Bolen
T <misceverything@gmail.com> writes:
> The more testing I do, I think you may be right..I was able to get it
> to work under a local admin account, and it worked under debug mode
> (which would also have been running as this user). I'm a bit
> surprised though - I was under the assumption that LocalSystem had
> rights to access the network?
Not from my past experience - the system account (LocalSystem for
services) can be surprising, in that it's pretty much unlimited access
to all local resources, but severely limited in a handful of cases,
one of which is any attempt to access the network. I can't recall for
sure if it's an absolute block, or if in some cases you can configure
around it (e.g., it might use a null session for remote shares which
can be enabled through the registry on the target machine). I've
basically stuck "LocalSystem = no network" in my head from past
experience.
So you can either install your service to run under your existing
account, or create an account specifically for running your service,
granting that account just the rights it needs.
-- David
== 2 of 2 ==
Date: Tues, Feb 9 2010 1:25 pm
From: David Bolen
David Bolen <db3l.net@gmail.com> writes:
> Not from my past experience - the system account (LocalSystem for
> services) can be surprising, in that it's pretty much unlimited access
> to all local resources, but severely limited in a handful of cases,
> one of which is any attempt to access the network. I can't recall for
> sure if it's an absolute block, or if in some cases you can configure
> around it (e.g., it might use a null session for remote shares which
> can be enabled through the registry on the target machine). I've
> basically stuck "LocalSystem = no network" in my head from past
> experience.
Given it's been a few years, I decided to try some tests, and the
above is too simplistic.
The LocalSystem account runs without any local Windows credentials
(e.g., not like a logged in user), which has several consequences.
One is that you can't access any network resources that require such
credentials (like shares). However, there's no sort of firewall
filtering or anything, so plain old TCP/IP connections are fine.
Unless, of course, the client being used also has other needs for
local Windows credentials, independent or as a pre-requisite to the
network operations.
So backing up a bit, the TCP/IP connection that plink is making is not
inherently disabled by running under LocalSystem, but it's certainly
possible that plink is trying to identify the user under which it is
operating to perhaps identify ssh keys or other local resources it
needs to operate. You might be able to cover this with command line
options (e.g., plink supports "-i" to specify a key file to use), but
you'll also need to ensure that the file you are referencing is
readable by the LocalSystem account.
One of the other responders had a very good point about locating plink
in the first place too. Services run beneath an environment that is
inherited from the service control manager process, and won't include
various settings that are applied to your user when logged in,
especially things like local path changes, and working directories.
Should you change the system path (via the environment settings),
you'll need to reboot for the service control manager to notice - I
don't think you can restart it without a reboot.
So it's generally safer to be very clear, and absolute when possible,
in a service for paths to external resources.
The prior advice of running the service as an identified user (e.g.,
with local credentials) is still good as it does remove most of these
issues since if you can run the script manually under that user you
know it'll work under service. But it's not a hard requirement.
If your script is dying such that a top level exception is being
raised you should be able to find it in the application event log. So
that might give further information on what about the different
environment is problematic.
You can also use the win32traceutil module to help with grabbing debug
output on the fly. Import the module in your service, which will
implicitly redirect stdout/stderr to a trace buffer. Run the same
win32traceutil module from the command line in another window. Then
start the service. Any stdout/stderr will be reflected in the other
window. Can't catch everything (suppressed exceptions, or I/O that
doesn't flow through the script's stdout/stderr), but again might help
point in the right direction.
-- David
==============================================================================
TOPIC: Hurry Up, Free Check Of $327 With Your Name.
http://groups.google.com/group/comp.lang.python/t/261e8c7f9fe25ec7?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 11:21 am
From: MILLIONARE
Hurry Up, Free Check Of $327 With Your Name.
Quickly open below website and click any one of the Red Color Text in
the website and enter your payeename and address where to get your
check.
The secret website link is
http://googleadsense-toppayingkeywords.blogspot.com/
==============================================================================
TOPIC: Ternary plus
http://groups.google.com/group/comp.lang.python/t/05afedbd6dc66a2c?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 10:47 am
From: Martin Drautzburg
Carl Banks wrote:
> You can have __add__ return a closure for the first addition, then
> perform the operation on the second one. Example (untested):
>
> class Closure(object):
> def __init__(self,t1,t2):
> self.t1 = t1
> self.t2 = t2
> def __add__(self,t3):
> # whole operation peformed here
> return self.t1 + self.t2 + t3
>
> class MySpecialInt(int):
> def __add__(self,other):
> return Closure(self,other)
>
>
> I wouldn't recommend it. Just use a function call with three
> arguments.
That's way cool.
<Flash of insight> Of course! - CURRYING!! If you can return closures
you can do everything with just single-parameter functions.</Flash of
insight>
BTW I am not really trying to add three objects, I wanted a third object
which controls the way the addition is done. Sort of like "/" and "//"
which are two different ways of doing division.
Anyways: thanks a lot.
==============================================================================
TOPIC: To (monkey)patch or not to (monkey)patch, that is the question
http://groups.google.com/group/comp.lang.python/t/49c9d1124ead9150?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 11:59 am
From: "sjdevnull@yahoo.com"
On Feb 9, 3:54 am, George Sakkis <george.sak...@gmail.com> wrote:
> I was talking to a colleague about one rather unexpected/undesired
> (though not buggy) behavior of some package we use. Although there is
> an easy fix (or at least workaround) on our end without any apparent
> side effect, he strongly suggested extending the relevant code by hard
> patching it and posting the patch upstream, hopefully to be accepted
> at some point in the future. In fact we maintain patches against
> specific versions of several packages that are applied automatically
> on each new build. The main argument is that this is the right thing
> to do, as opposed to an "ugly" workaround or a fragile monkey patch.
> On the other hand, I favor practicality over purity and my general
> rule of thumb is that "no patch" > "monkey patch" > "hard patch", at
> least for anything less than a (critical) bug fix.
I'd monkey patch for the meantime, but send a hard patch in the hopes
of shifting the maintenance burden to someone else. (Plus maybe help
out the upstream project and other people, I guess)
==============================================================================
TOPIC: Modifying Class Object
http://groups.google.com/group/comp.lang.python/t/fd36962c4970ac48?hl=en
==============================================================================
== 1 of 4 ==
Date: Tues, Feb 9 2010 12:02 pm
From: "Alf P. Steinbach"
* Duncan Booth:
> "Alf P. Steinbach" <alfps@start.no> wrote:
>
>> A copyable reference is a pointer. That is, a "pointer", in e.g. the
>> Java sense,
>> and in the general language independent sense, means a copyable
>> reference -- as illustrated e.g. in the Stanford computer science
>> 101 course page I
>> referred you to earlier, with C versus Java pointers illustrated in
>> the concrete.
>
> The fact that C style pointers are used internally is an detail of the
> CPython implementation.
Your statement seems pretty irrelevant to anything.
It's almost hilarious, quoting a single paragraph about how irrelevant the C
pointer is, and responding with something like that.
Do you understand that you're restating (in the form of exemplifying) what
you're quoting?
> In CPython objects once created remain in the same memory location (and
> their id is their address). Compare that to IronPython where the objects
> themselves can move around in memory so they have no fixed address. Try
> comparing the IronPython implementation to C pointers and you'll cause a
> lot of confusion. e.g. someone might think the id() value is in some way
> related to an address.
Did you /read/ what you quoted?
> Ruby implements integers without using any pointers at all: there's nothing
> in the Python specification which prevents a Python implementation doing
> the same for small integers, in fact I believe it has been tried but wasn't
> found to improve performance.
All theree of your points about Python are wrong; I don't know about the Ruby point.
First, the current Python language specification formally prevents the
optimization you mention, because there's no support for binding to do anything
but direct binding leaving object identities unchanged.
But in practice that's no big deal though: I can't imagine any code relying on
identities of completely immutable objects.
Second, even the variant that was tried improved performance.
But it would reportedly have wreaked havoc with imperfect C code.
Third, the optimization doesn't do away with pointers. If it did then it would
transform the language completely. The user's view is still one where names
denote pointers.
> The terminology of 'objects', 'names', 'references' describes an abstract
> machine. The Python runtime can implement it in any way it chooses so long
> as those semantics are preserved. One implementation involves 'pointers',
It seems that you're thinking of C pointers.
That's pretty dumb since
(1) it doesn't make sense, and
(2) it has been mentioned in almost every article in this thread, including
my first, and including the single paragraph that *you quoted above*,
which was only about that, that
we're not talking about C pointers here.
Python names denote pointers by definition (of pointer).
> but that word implies other baggage which is not a required part of the
> model.
The word itself doesn't imply other baggage, no.
It might help to *read* what you're quoting, try to follow references, so on.
Cheers & hth.,
- Alf
== 2 of 4 ==
Date: Tues, Feb 9 2010 12:04 pm
From: "Alf P. Steinbach"
* Steve Holden:
> Alf P. Steinbach wrote:
>> * Stephen Hansen:
> [...]
>>> I've heard that before, and have no idea why, nor any real interest in
>>> solving it: I don't want to read cpl via Usenet, and prefer to read it
>>> as a mailing list. Somewhere between Gmail->python.org->python.org
>>> <http://python.org>'s usenet server->the world, some people don't seem
>>> to get my posts. Yet it shows up on some news servers, not others.
>>>
>>> No idea. Nothing I know of can solve it.
>> Not sure, but perhaps it's possible to mail directly to gmane?
>>
> Is there *any* problem you don't have a fatuous answer for?
I thought the answer could help.
You thought you cold do a bit of ad hominem attack.
That's the difference between us.
Cheers,
- Alf
== 3 of 4 ==
Date: Tues, Feb 9 2010 12:39 pm
From: Steve Holden
Alf P. Steinbach wrote:
> * Steve Holden:
>> Alf P. Steinbach wrote:
>>> * Stephen Hansen:
>> [...]
>>>> I've heard that before, and have no idea why, nor any real interest in
>>>> solving it: I don't want to read cpl via Usenet, and prefer to read it
>>>> as a mailing list. Somewhere between Gmail->python.org->python.org
>>>> <http://python.org>'s usenet server->the world, some people don't seem
>>>> to get my posts. Yet it shows up on some news servers, not others.
>>>>
>>>> No idea. Nothing I know of can solve it.
>>> Not sure, but perhaps it's possible to mail directly to gmane?
>>>
>> Is there *any* problem you don't have a fatuous answer for?
>
> I thought the answer could help.
>
> You thought you cold do a bit of ad hominem attack.
>
> That's the difference between us.
>
Well, the way I see it, you assumed you knew better than Stephen, and
insisted on proposing a solution to a problem that he clearly stated he
had no interest in. I'm not quite sure, given that, what the point of
the advice was.
However, my question was genuine, based on your observed behavior. I
agree I might have phrased it more politely, but I do find your
self-assurance somewhat irritating.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
== 4 of 4 ==
Date: Tues, Feb 9 2010 1:08 pm
From: "Alf P. Steinbach"
* Steve Holden:
> Alf P. Steinbach wrote:
>> * Steve Holden:
>>> Alf P. Steinbach wrote:
>>>> * Stephen Hansen:
>>> [...]
>>>>> I've heard that before, and have no idea why, nor any real interest in
>>>>> solving it: I don't want to read cpl via Usenet, and prefer to read it
>>>>> as a mailing list. Somewhere between Gmail->python.org->python.org
>>>>> <http://python.org>'s usenet server->the world, some people don't seem
>>>>> to get my posts. Yet it shows up on some news servers, not others.
>>>>>
>>>>> No idea. Nothing I know of can solve it.
>>>> Not sure, but perhaps it's possible to mail directly to gmane?
>>>>
>>> Is there *any* problem you don't have a fatuous answer for?
>> I thought the answer could help.
>>
>> You thought you cold do a bit of ad hominem attack.
>>
>> That's the difference between us.
>>
> Well, the way I see it, you assumed you knew better than Stephen, and
> insisted on proposing a solution to a problem that he clearly stated he
> had no interest in.
You're going into motivations, that it seems to me that you're projecting,
saying that any helpful suggestion mean that one thinks one knows better and
implies a desire to demonstrate imagined superiority.
You're trying to portray a helping hand as a negative personal characteristic of
the helper.
"the only reason that guy tries to help you is because he wishes to show how
superior he (thinks he) is".
That's your style in a fair number of postings, and now here:
* ad hominem attack,
* projection (at least the way I read it), and
* inject - noise - about - something - completely - irrelevant
Note that readers can easily guess about motivations for the last.
> I'm not quite sure, given that, what the point of the advice was.
There are many people who read just the Usenet group, e.g. via Google groups.
When you say you don't understand the point of the advice, you're saying that
* those people don't matter, and that
* it doesn't matter whether they can read Stephen Hansen's articles.
That's
* slighting Stephen Hansen, and
* showing off an extreme ego-centric view of the world,
sorry.
> However, my question was genuine, based on your observed behavior. I
> agree I might have phrased it more politely, but I do find your
> self-assurance somewhat irritating.
Thanks. :-)
Cheers & hth.,
- Alf
==============================================================================
TOPIC: Tangling with mathplotlib(MPL) on XP and Win7 -- show() stopper
http://groups.google.com/group/comp.lang.python/t/84b2f3125d4d3ab6?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 12:02 pm
From: "W. eWatson"
Solved. I need to get into the interactive mode. Never heard of it until
this morning.
==============================================================================
TOPIC: errno 107 socket.recv issue
http://groups.google.com/group/comp.lang.python/t/ff1ce95292f1a5ec?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 12:39 pm
From: Steve Holden
Jordan Apgar wrote:
> On Feb 9, 1:51 pm, Jean-Michel Pichavant <jeanmic...@sequans.com>
[...]
>> you swapped port & hostID in your call
>>
>> JM
>
> tThanks guys it's working now... feel a little stupid though.
Cool!
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
==============================================================================
TOPIC: New to Python
http://groups.google.com/group/comp.lang.python/t/429d23f88afefef6?hl=en
==============================================================================
== 1 of 2 ==
Date: Tues, Feb 9 2010 1:00 pm
From: "Quin"
s = f.readline()
if 'mystring' in s: print 'foundit'
if 'mystring' not in s: print 'not found'
if 'mystring' in s:
print 'processing'
this generates output:
not found
processing
so, it doesn't find the substring, but goes into processing code anyway.
This is using IronPython
== 2 of 2 ==
Date: Tues, Feb 9 2010 2:11 pm
From: John Gordon
In <14Cdnb6rubmdUOzWnZ2dnUVZ_gadnZ2d@posted.grandecom> "Quin" <quindennis@grandecom.net> writes:
> s = f.readline()
> if 'mystring' in s: print 'foundit'
> if 'mystring' not in s: print 'not found'
> if 'mystring' in s:
> print 'processing'
> this generates output:
> not found
> processing
> so, it doesn't find the substring, but goes into processing code anyway.
I got this output when f contained 'mystring':
foundit
processing
And this output when f did not contain 'mystring':
notfound
I have no idea why it would have worked otherwise for you. When you posted
your question, did you type the code by hand? Perhaps you made a mistake.
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
==============================================================================
TOPIC: How to measure elapsed time under Windows?
http://groups.google.com/group/comp.lang.python/t/340c476d0357a7bd?hl=en
==============================================================================
== 1 of 3 ==
Date: Tues, Feb 9 2010 1:19 pm
From: Grant Edwards
On 2010-02-09, Grant Edwards <invalid@invalid.invalid> wrote:
> On 2010-02-09, Jean-Michel Pichavant <jeanmichel@sequans.com> wrote:
>> Did you try with the datetime module ?
>
> No. What mechanism does it use to get the current date/time?
>
>> import datetime
>> t0 = datetime.datetime.now()
>> t1 = t0 - datetime.datetime.now()
>> t1.microseconds
>> Out[4]: 644114
>
> That looks very broken to me. I need to measure stuff in the
> 1-20ms range, and the smallest value you can measure using the
> method above appears to be 640ms. Thats almost 2/3 of a second.
Duh. It just occurred to me that was done interactively. I'll
give the datetime module a try once I reboot my test machine
back into Windows.
--
Grant Edwards grante Yow! Is this sexual
at intercourse yet?? Is it,
visi.com huh, is it??
== 2 of 3 ==
Date: Tues, Feb 9 2010 1:45 pm
From: Grant Edwards
On 2010-02-09, Jean-Michel Pichavant <jeanmichel@sequans.com> wrote:
> Grant Edwards wrote:
>> What's the correct way to measure small periods of elapsed
>> time. I've always used time.clock() in the past:
>>
>> start = time.clock()
>> [stuff being timed]
>> stop = time.clock()
>>
>> delta = stop-start
>>
>>
>> However on multi-processor machines that doesn't work.
>> Sometimes I get negative values for delta. According to
>> google, this is due to a bug in Windows that causes the value
>> of time.clock() to be different depending on which core in a
>> multi-core CPU you happen to be on. [insert appropriate
>> MS-bashing here]
>>
>> Is there another way to measure small periods of elapsed time
>> (say in the 1-10ms range)?
>>
>> Is there a way to lock the python process to a single core so
>> that time.clock() works right?
> Did you try with the datetime module ?
>
> import datetime
> t0 = datetime.datetime.now()
> t1 = t0 - datetime.datetime.now()
> t1.microseconds
> Out[4]: 644114
Doesn't work. datetime.datetime.now has granularity of
15-16ms.
Intervals much less that that often come back with a delta of
0. A delay of 20ms produces a delta of either 15-16ms or
31-32ms
--
Grant Edwards grante Yow! I'm receiving a coded
at message from EUBIE BLAKE!!
visi.com
== 3 of 3 ==
Date: Tues, Feb 9 2010 2:00 pm
From: Grant Edwards
On 2010-02-09, Grant Edwards <invalid@invalid.invalid> wrote:
> On 2010-02-09, Jean-Michel Pichavant <jeanmichel@sequans.com> wrote:
>> Grant Edwards wrote:
>>> What's the correct way to measure small periods of elapsed
>>> time. I've always used time.clock() in the past:
>>>
>>> start = time.clock()
>>> [stuff being timed]
>>> stop = time.clock()
>>>
>>> delta = stop-start
>>>
>>>
>>> However on multi-processor machines that doesn't work.
>>> Sometimes I get negative values for delta. According to
>>> google, this is due to a bug in Windows that causes the value
>>> of time.clock() to be different depending on which core in a
>>> multi-core CPU you happen to be on. [insert appropriate
>>> MS-bashing here]
>>>
>>> Is there another way to measure small periods of elapsed time
>>> (say in the 1-10ms range)?
>>>
>>> Is there a way to lock the python process to a single core so
>>> that time.clock() works right?
>
>> Did you try with the datetime module ?
>>
>> import datetime
>> t0 = datetime.datetime.now()
>> t1 = t0 - datetime.datetime.now()
>> t1.microseconds
>> Out[4]: 644114
>
> Doesn't work. datetime.datetime.now has granularity of
> 15-16ms.
time.time() exhibits the same behavior, so I assume that
datetime.datetime.new() ends up making the same libc/system
call as time.time(). From what I can grok of the datetime
module source code, it looks like it's calling gettimeofday().
I can't find any real documentation on the granularity of Win32
gettimeofday() other than a blog post that claims it is 10ms
(which doesn't agree with what my tests show).
--
Grant Edwards grante Yow! I feel better about
at world problems now!
visi.com
==============================================================================
TOPIC: Python-URL! - weekly Python news and links (Feb 9)
http://groups.google.com/group/comp.lang.python/t/0e861974ce5d2b5f?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 1:18 pm
From: "Gabriel Genellina"
En Tue, 09 Feb 2010 12:32:54 -0300, Marius Gedminas <mgedmin@gmail.com>
escribió:
> The last three URLs are malformed:
Sorry... It happens even in the best of families :)
These are the right ones:
There is no module in the standard library to handle filesystem paths in
an OO way - but why?
http://groups.google.com/group/comp.lang.python/t/f580fb3763208425/
A "History Channel" special: how the way a TAB key was interpreted changed
over time
http://groups.google.com/group/comp.lang.python/t/82d9181fcd31ffe4/
After a false start, finally we get our first "Is it Call-By-Value or
Call-By-Reference?" thread of the year!
http://groups.google.com/group/comp.lang.python/t/fd36962c4970ac48/
--
Gabriel Genellina
==============================================================================
TOPIC: Python and Ruby
http://groups.google.com/group/comp.lang.python/t/dfe4f6c60032755e?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 1:41 pm
From: Jonathan Gardner
On Feb 9, 1:51 am, waku <w...@idi.ntnu.no> wrote:
> 'stupid', 'wrong', 'deficient', 'terrible', ... you're using strong
> words instead of concrete arguments, it might intimidate your
> opponents, but is hardly helpful in a fair discussion.
>
In today's day and age, I don't know how a text editor which cannot do
simple indentation can be considered anything but "stupid", "wrong",
"deficient", and "terrible". There is simply no excuse for this kind
of behavior on the part of the text editor.
I mean, how long has vi had the auto indent feature? How many decades
has emacs supported the same? This isn't new technology, or difficult
technology to implement. It's not even non-standard anymore. Heck, far
more advanced features, such as syntax highlighting, are standard in
all text editors.
Your problem is you're using something like Windows Notepad to edit
your code. Windows Notepad is a terrible tool for writing anything,
let alone writing code. Why in the world would any programming
language adapt itself to the mental deficiencies of Windows Notepad? I
mean, if you were an artist, would you use MS Paint to do anything
serious? If you did, would you complain that the art world has a
problem because they don't accept your paintings?
I strongly suggest you download one of the *hundreds* of free text
editors available for the Windows platform that give you the
indentation features you so sorely lack. I suggest ViM, though it has
a steep learning curve.
==============================================================================
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 1 ==
Date: Tues, Feb 9 2010 1:42 pm
From: seth
There is something you could possibly help me with.
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?
What is worse, at the time of reading it we get the error below the
extracted code, on Os X 10.5:
if os.path.exists( tarname )and tarfile.is_tarfile( tarname ):
try:
datastore_tarfile=tarfile.open( tarname, 'r:gz' )
print "Successfully opened the tarball: %s"%tarname
members=datastore_tarfile.getnames()
for dbmFile in members:
datastore_tarfile.extract( dbmFile )
print "Extracting Realizations File: %s"%dbmFile
realizations=shelve.open( dbmFile, 'c', 2, writeback =
False )
Successfully opened the tarball: datastore.tar.gz
Extracting Realizations File: realizations.dbm.db
<class 'bsddb.error'>
(22, 'Invalid argument')
This does not happen on Windows XP with Python 2.5.
Does anyone know what is happening on Os X?
Any comments and suggestions will be greatly appreciated. Thank you
very much in advance.
==============================================================================
TOPIC: PostgreSQL driver for Python applications that supports bytea correctly?
http://groups.google.com/group/comp.lang.python/t/70a061b40f4c8cc7?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 1:43 pm
From: Jonathan Gardner
On Feb 9, 7:27 am, CyclingGuy <ericthecycl...@gmail.com> wrote:
> Can anyone recommend a PostgreSQL driver for Python that supports
> selecting and inserting bytea types?
>
Can you name some that don't?
==============================================================================
TOPIC: Programing family
http://groups.google.com/group/comp.lang.python/t/9c369186368028ed?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 1:50 pm
From: "Gabriel Genellina"
En Mon, 08 Feb 2010 22:39:58 -0300, AON LAZIO <aonlazio@gmail.com>
escribió:
> I have thought funny things
> If we think all languages are like a family
> I could draft them like this (Python base)
Have a look at:
http://oreilly.com/news/languageposter_0504.html
--
Gabriel Genellina
==============================================================================
TOPIC: Problem Regarding Queue
http://groups.google.com/group/comp.lang.python/t/74b045cda204e5ee?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 2:06 pm
From: mukesh tiwari
Could some one please tell what is wrong with this code. I am trying
to use Queue in this program but i am getting error
Traceback (most recent call last):
File "/home/user/NetBeansProjects/NewPythonProject2/src/
Pollard_rho.py", line 80, in <module>
factor(n)
File "/home/user/NetBeansProjects/NewPythonProject2/src/
Pollard_rho.py", line 59, in factor
Q_1=Queue()
NameError: global name 'Queue' is not defined.
As i am new to python so kindly pardon me if i sound stupid.
Here is the code
# To change this template, choose Tools | Templates
# and open the template in the editor.
__author__="Mukesh Tiwari"
__date__ ="$Feb 10, 2010 1:35:26 AM$"
import random
import sys
def gcd(a,b):
while b:
a,b=b,a%b
return a
def rabin_miller(p):
if(p<2):
return False
if(p!=2 and p%2==0):
return False
s=p-1
while(s%2==0):
s>>=1
for i in xrange(10):
a=random.randrange(p-1)+1
temp=s
mod=pow(a,temp,p)
while(temp!=p-1 and mod!=1 and mod!=p-1):
mod=(mod*mod)%p
temp=temp*2
if(mod!=p-1 and temp%2==0):
return False
return True
def pollard(n):
if(n%2==0):
return 2;
x=random.randrange(2,1000000)
c=random.randrange(2,1000000)
y=x
d=1
while(d==1):
x=(x*x+c)%n
y=(y*y+c)%n
y=(y*y+c)%n
d=gcd(x-y,n)
if(d==n):
break;
return d;
def factor(n):
#if(rabin_miller(n)):
# print n
# return
#d=pollard(n)
#if(d!=n):
# factor(d)
# factor(n/d)
#else:
# factor(n)
Q_1=Queue()
Q_2=Queue()
Q_1.put(n)
while(not Q_1.empty()):
l=Q_1.get()
if(rabin_miller(l)):
Q_2.put(l)
continue
d=pollard(l)
if(d==l):Q_1.put(l)
else:
Q_1.put(d)
Q_1.put(l/d)
while(not Q_2.empty()):
print Q_2.get()
if __name__ == "__main__":
while(True):
n=input();
factor(n)
==============================================================================
TOPIC: ANN: obfuscate
http://groups.google.com/group/comp.lang.python/t/6374e775e474ee1a?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 2:10 pm
From: Simon Brunning
On 9 February 2010 16:29, Robert Kern <robert.kern@gmail.com> wrote:
> On 2010-02-09 09:37 AM, Daniel Fetchinson wrote:
>> If the code base stabilizes in a production version after losing the
>> alphas and betas they would be a great addition to the stdlib, I
>> think.
>
> Why?
I agree. Why wait? Put them in the stdlib now!
--
Cheers,
Simon B.
==============================================================================
TOPIC: equivalent of Ruby's Pathname?
http://groups.google.com/group/comp.lang.python/t/f580fb3763208425?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 2:28 pm
From: Chris Rebert
On Tue, Feb 9, 2010 at 6:00 AM, Phlip <phlip2005@gmail.com> wrote:
<snip>
> Ah, now we get down to the root of the problem. Because Python is so
> stuck on the "one best way to do it" mentality, language bigotry
> prevented the Committee from picking from among several equally valid
> but non-best options. And after 20 years of growth, Python still has
> no Pathname class. What a mature community! C-:
Committee? I think you have us confused with C++...
*wink*,
Chris
==============================================================================
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