I decided to create a decorator like.
import cProfile
def debug_time(method):
def timed(*args, **kw):
prof = cProfile.Profile()
prof.enable(subcalls=False, builtins=False)
result = prof.runcall(method, *args, **kw)
#prof.print_stats()
msg = "\n\n\n\n###
I have developed a LDAP auth system using python-ldap module.
Using that i can validate username and password, fetch user and
groups info from LDAP directory.
Now i want to implement ldap proxy user bind to the ldap server.
I googled and find this http://ldapwiki.willeke.com/wiki/LDAPProxyUser
But
in 671891 20120210 212545 Olive wrote:
>In the datetime module, it has support for a notion of timezone but is
>it possible to use one of the available timezone (I am on Linux). Linux
>has a notion of timezone (in my distribution, they are stored
>in /usr/share/zoneinfo). I would lik
在 2012年2月11日星期六UTC+8上午2时57分34秒,John Nagle写道:
> On 2/10/2012 10:14 AM, Nathan Rice wrote:
> >>> Lets also not forget that knowing an object is immutable lets you do a
> >>> lot of optimizations; it can be inlined, it is safe to convert to a
> >>> contiguous block of memory and stuff in cache, etc.
On Feb 10, 7:52 pm, 7stud <7s...@excite.com> wrote:
I don't know if this helps, but I notice when I initially do this:
shelve.open('data22')
the file is saved as 'data22.db'. But on subsequent calls to
shelve.open(), if I use the file name 'data22.db', I get a different
error:
--output:--
**
On Feb 10, 7:48 pm, 7stud <7s...@excite.com> wrote:
>
> But I cannot get a class that inherits from collections.defaultdict to
> shelve itself:
>
> import collections as c
> import shelve
>
> class Dog(c.defaultdict):
> def __init__(self):
> super().__init__(int, Joe=0)
> print(
The following code demonstrates that a collections.defaultdict is
shelve worthy:
import shelve
import collections as c
dd = c.defaultdict(int)
dd["Joe"] = 3
print(dd)
my_shelve = shelve.open('data.shelve')
my_shelve['strike_record'] = dd
my_shelve.close()
my_shelve = shelve.open('data.shelve'
Still messing with .dbf files?
Somebody brought you a 15 year old floppy, which still luckily (?)
worked, and now wants that ancient data?
dbf to the rescue!
Supported tables/features
=
- dBase III
- FoxPro
- Visual FoxPro supported
- Null value
Supported fiel
Righard van Roy writes:
> I want to add an item to a list, except if the evaluation of that item
> results in an exception.
This may be overkill and probably slow, but perhaps most in the spirit
that you're asking.
from itertools import chain
def r(x):
if x > 3:
rais
On Fri, 2012-02-10 at 14:52 -0800, Paul Rubin wrote:
> Fabric Paul writes:
> > Hi Stefan - Thanks for the heads up. Fabric Engine has been going for
> > about 2 years now. Registered company etc. I'll be sure to refer to it
> > as Fabric Engine so there's no confusion. We were unaware there was a
Am 10.02.2012 22:06, schrieb John Gordon:
> Is there an automated way to catch errors like these? I'm using the
> compileall module to build my program and it does catch some errors
> such as incorrect indentation, but not errors like the above.
Write unit tests and use coverage to aim for 100% c
On Fri, Feb 10, 2012 at 3:01 PM, Righard van Roy wrote:
> Hello,
>
> I want to add an item to a list, except if the evaluation of that item
> results in an exception.
> I could do that like this:
>
> def r(x):
> if x > 3:
> raise(ValueError)
>
> try:
> list.append(r(1))
> except:
>
In Kev Dwyer
writes:
> *Any* instrumentation code is going to affect performance.
Funny story about that...
I wanted to profile some code of mine, and a colleague recommended the
'hotshot' module.
It's pretty easy to use: there are functions to start profiling, stop
profiling and print resul
Hello,
I want to add an item to a list, except if the evaluation of that item
results in an exception.
I could do that like this:
def r(x):
if x > 3:
raise(ValueError)
try:
list.append(r(1))
except:
pass
try:
list.append(r(5))
except:
pass
This looks rather clumbsy t
Fabric Paul writes:
> Hi Stefan - Thanks for the heads up. Fabric Engine has been going for
> about 2 years now. Registered company etc. I'll be sure to refer to it
> as Fabric Engine so there's no confusion. We were unaware there was a
> python tool called Fabric.
There will still be confusion.
Thanks for responding. Rather than take this discussion too far where
it's quite off-topic, I'll respond briefly and ask for a change of forum
if we want to continue.
Ethan Furman writes:
> Ben Finney wrote (from signature):
> > “It's a terrible paradox that most charities are driven by religi
sajuptpm wrote:
> Hi,
>
> Yes i saw profile module,
> I think i have to do function call via
>
> cProfile.run('foo()')
>
> I know, we can debug this way.
>
> But, i need a fixed logging system and want to use it in production.
> I think, we can't permanently include profile's debugging c
On 2/10/2012 6:11 AM, mloskot wrote:
The intent of xyz.flag is that it is a value set by the module internally.
xyz is a module wrapping a C library.
The C library defines concept of a global flag set by the C functions at
some events,
so user can check value of this flag.
I can provide access t
On Thu, 09 Feb 2012 22:27:50 -0500, Terry Reedy wrote:
> On 2/9/2012 8:04 PM, Steven D'Aprano wrote:
>
>> Python happily violates "consenting adults" all over the place. We have
>> properties, which can easily create read-only and write-once
>> attributes.
>
> So propose that propery() work at m
Ben Finney wrote (from signature):
> “It's a terrible paradox that most charities are driven by religious
> belief. . . . if you think altruism without Jesus is not altruism,
> then you're a dick.” —Tim Minchin, 2010-11-28
1) Why is it paradoxical? If anything it's a sad commentary on those
who
On Fri, Feb 10, 2012 at 1:25 PM, Olive wrote:
> In the datetime module, it has support for a notion of timezone but is
> it possible to use one of the available timezone (I am on Linux). Linux
> has a notion of timezone (in my distribution, they are stored
> in /usr/share/zoneinfo). I would like t
On Sat, Feb 11, 2012 at 7:04 AM, Thomas Philips wrote:
> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in x:
> if i % 2 == 0:
> x.remove(i)
Just a quickie, is there a reason you can't use a list comprehension?
x = [i for i in x if i % 2]
ChrisA
--
http://mail.python.org/mailm
In <20120210222545.4cbe6...@bigfoot.com> Olive writes:
> In the datetime module, it has support for a notion of timezone but is
> it possible to use one of the available timezone (I am on Linux). Linux
> has a notion of timezone (in my distribution, they are stored
> in /usr/share/zoneinfo). I wo
John Gordon writes:
> Is there an automated way to catch errors like these?
Use a static code checker, such as ‘pyflakes’ (simple but limited) or
‘pylint’ (complex but highly configurable) to catch these and many other
problems in Python code.
--
\ “It's a terrible paradox that most
In the datetime module, it has support for a notion of timezone but is
it possible to use one of the available timezone (I am on Linux). Linux
has a notion of timezone (in my distribution, they are stored
in /usr/share/zoneinfo). I would like to be able 1) to know the current
timezone and 2) to be
John Gordon wrote:
> Recently I was been bitten by some stupid errors in my code, and I'm
> wondering if there's a simple way to catch them.
>
Pyflakes is another static checker that can catch these sorts of errors.
Cheers,
Kev
--
http://mail.python.org/mailman/listinfo/python-list
On 10 February 2012 21:06, John Gordon wrote:
> Recently I was been bitten by some stupid errors in my code, and I'm
> wondering if there's a simple way to catch them.
>
> One error was of the form:
>
> my_object.some_function()
>
> .. when I hadn't declared an object named "my_object".
>
> The o
Recently I was been bitten by some stupid errors in my code, and I'm
wondering if there's a simple way to catch them.
One error was of the form:
my_object.some_function()
.. when I hadn't declared an object named "my_object".
The other error was similar:
x = my_module.CONSTANT
.. when I h
On Thu, 9 Feb 2012 17:43:58 -0800
Chris Rebert wrote:
> On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote:
> > hmmm, okay.
> >
> > So how would you round UP always? Say the number is 3219, so you
> > want 3300 returned.
>
> http://stackoverflow.com/questions/17944/how-to-round-up-the-result-of-integ
On 02/10/2012 04:00 PM, Peter Otten wrote:
Sorry, you didn't mention that in the post I responded to and I didn't
follow the thread closely.
I found a description for declare_namespace() at
http://peak.telecommunity.com/DevCenter/PkgResources
but the text explaining the function is completely u
Thanks for the insight. I saw the behavious as soon as I extended x
with a bunch of 0's
>>> x = list(range(10))
>>> x.extend([0]*10)
>>> x
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>> for i in reversed(x):
if i % 2 == 0:
x.remove(i)
>>> x
[1, 3, 5, 7, 9
On 10/02/2012 20:04, Thomas Philips wrote:
In the past, when deleting items from a list, I looped through the
list in reverse to avoid accidentally deleting items I wanted to keep.
I tried something different today, and, to my surprise, was able to
delete items correctly, regardless of the direct
Héllo,
I did it, it wasn't that difficult actually.
the source is available @ https://github.com/amirouche/jsonir
there is example :
https://github.com/amirouche/jsonir/blob/master/example.py
What makes the implementation of __json__ awkward is the iterencode support
of simplejson that I kept.
On Fri, Feb 10, 2012 at 1:04 PM, Thomas Philips wrote:
> In the past, when deleting items from a list, I looped through the
> list in reverse to avoid accidentally deleting items I wanted to keep.
> I tried something different today, and, to my surprise, was able to
> delete items correctly, regar
In the past, when deleting items from a list, I looped through the
list in reverse to avoid accidentally deleting items I wanted to keep.
I tried something different today, and, to my surprise, was able to
delete items correctly, regardless of the direction in which I looped,
in both Python 3.2.2.
On 2/10/2012 10:14 AM, Nathan Rice wrote:
Lets also not forget that knowing an object is immutable lets you do a
lot of optimizations; it can be inlined, it is safe to convert to a
contiguous block of memory and stuff in cache, etc. If you know the
input to a function is guaranteed to be frozen
>> Lets also not forget that knowing an object is immutable lets you do a
>> lot of optimizations; it can be inlined, it is safe to convert to a
>> contiguous block of memory and stuff in cache, etc. If you know the
>> input to a function is guaranteed to be frozen you can just go crazy.
>> Being
On Feb 10, 4:58 am, Arnaud Delobelle wrote:
> On 10 February 2012 06:21, Ian Kelly wrote:
>
>
>
>
>
> > (3219 + 99) // 100 * 100
> >> 3300
> > (3289 + 99) // 100 * 100
> >> 3300
> > (328678 + 99) // 100 * 100
> >> 328700
> > (328 + 99) // 100 * 100
> >> 400
>
> >> Those are all ro
On Feb 10, 12:21 pm, Stefan Behnel wrote:
> Fabric Paul, 10.02.2012 17:04:
>
> > Fabric is a high-performance multi-threading engine that
> > integrates with dynamic languages.
>
> Hmm, first of all, fabric is a tool for automating
> admin/deployment/whatever tasks:
>
> http://pypi.python.org/pypi
Fabric Paul, 10.02.2012 17:04:
> Fabric is a high-performance multi-threading engine that
> integrates with dynamic languages.
Hmm, first of all, fabric is a tool for automating
admin/deployment/whatever tasks:
http://pypi.python.org/pypi/Fabric/1.3.4
http://docs.fabfile.org/en/1.3.4/index.html
Hi Peter
On Feb 10, 11:10 am, Peter Otten <__pete...@web.de> wrote:
[...]
> > Hmm ... thanks for mentioning this feature, I didn't know of it
> > before. Sounds great, except that I gather it needs Python >2.5? I'm
> > stuck with v2.4 at the moment unfortunately...
>
> You can import and run exp
On Fri, Feb 10, 2012 at 8:53 AM, Nathan Rice
wrote:
> Lets also not forget that knowing an object is immutable lets you do a
> lot of optimizations; it can be inlined, it is safe to convert to a
> contiguous block of memory and stuff in cache, etc. If you know the
> input to a function is guaran
On Fri, Feb 10, 2012 at 5:08 AM, Chris Angelico wrote:
> On Fri, Feb 10, 2012 at 1:30 PM, Nathan Rice
> wrote:
>> The only thing needed to avoid the hash collision is that your hash
>> function is not not 100% predictable just by looking at the python
>> source code. I don't see why every dict w
Hi all - just letting you know that we recently integrated Fabric with
Python. Fabric is a high-performance multi-threading engine that
integrates with dynamic languages. We're releasing soon (probably
under AGPL), and we just released these benchmarks.
http://fabric-engine.com/2012/02/fabric-engi
Andrea Crotti wrote:
> On 02/10/2012 03:27 PM, Peter Otten wrote:
>> The package a will be either a.c/a/ or a.b/a/ depending on whether
>> a.c/ or a.b/ appears first in sys.path. If it's a.c/a, that does not
>> contain a c submodule or subpackage.
>
>
> I would agree if I didn't have this declar
Peter Otten wrote:
> If it's a.c/a, that does not contain a c submodule or subpackage.
Sorry, I meant a.b/a
--
http://mail.python.org/mailman/listinfo/python-list
On 02/10/2012 03:27 PM, Peter Otten wrote:
The package a will be either a.c/a/ or a.b/a/ depending on whether
a.c/ or a.b/ appears first in sys.path. If it's a.c/a, that does not
contain a c submodule or subpackage.
I would agree if I didn't have this declaration
__import__('pkg_resources').
Andrea Crotti wrote:
> Ok now it's getting really confusing, I tried a small example to see
> what is the real behaviour,
> so I created some package namespaces (where the __init__.py declare the
> namespace package).
>
>/home/andrea/test_ns:
>total used in directory 12 available 5655372
On 02/10/2012 03:06 PM, Dave Angel wrote:
Yes, you've got periods in your directory names. A period means
something special within python, and specifically within the import.
When you say from a.c import api
You're telling it:from package a get module c, and from there
impoort the sy
On 02/10/2012 09:51 AM, Andrea Crotti wrote:
Ok now it's getting really confusing, I tried a small example to see
what is the real behaviour,
so I created some package namespaces (where the __init__.py declare the
namespace package).
/home/andrea/test_ns:
total used in directory 12 available 565
Ok now it's getting really confusing, I tried a small example to see
what is the real behaviour,
so I created some package namespaces (where the __init__.py declare the
namespace package).
/home/andrea/test_ns:
total used in directory 12 available 5655372
drwxr-xr-x 3 andrea andrea 4096 F
Please don't top post.
On 10/02/2012 12:59, Saju M wrote:
Yes i saw profile module,
I think, i have to do function call via
cProfile.run('foo()')
I know, we can debug this way.
But, I need a fixed logging system and want to use it in production.
I think, we can't permanently include profi
On 02/10/2012 08:08 AM, Andrea Crotti wrote:
I think I finally located the issue with the sys.path extension.
The problem is that I have many namespace directories, for example
lib:
- sub1
- sub2
lib:
- sub3
- sub4
But to have everything working I had lib.sub3 in easy-install.pth.
Now i
I think I finally located the issue with the sys.path extension.
The problem is that I have many namespace directories, for example
lib:
- sub1
- sub2
lib:
- sub3
- sub4
But to have everything working I had lib.sub3 in easy-install.pth.
Now if I try to add something else to the path it d
Hi,
Yes i saw profile module,
I think i have to do function call via
cProfile.run('foo()')
I know, we can debug this way.
But, i need a fixed logging system and want to use it in production.
I think, we can't permanently include profile's debugging code
in source code,
will cause any
Yes i saw profile module,
I think, i have to do function call via
cProfile.run('foo()')
I know, we can debug this way.
But, I need a fixed logging system and want to use it in production.
I think, we can't permanently include profile's debugging code in
source code,
will cause any perfor
On Fri, Feb 10, 2012 at 6:12 PM, Saju M wrote:
> Hi,
>
> Yes i saw profile module,
> I think i have to do function call via
>
> cProfile.run('foo()')
>
> I know, we can debug this way.
>
> But i need a fixed logging system ..
>
>
>
> On Fri, Feb 10, 2012 at 6:08 PM, Arnaud Delobelle wrote:
>
>> O
Hi,
Yes i saw profile module,
I think i have to do function call via
cProfile.run('foo()')
I know, we can debug this way.
But i need a fixed logging system ..
On Fri, Feb 10, 2012 at 6:08 PM, Arnaud Delobelle wrote:
> On 10 February 2012 12:30, sajuptpm wrote:
> > Hi,
> >
> > I want to lo
On 10 February 2012 12:30, sajuptpm wrote:
> Hi,
>
> I want to log time taken to complete database requests inside a method/
> function using decorator . is it possible
> I think, i have to inject log code inside the method/fuctions or
> modify it.
> I wrote a decorator to log taken by a met
Hi,
I want to log time taken to complete database requests inside a method/
function using decorator . is it possible
I think, i have to inject log code inside the method/fuctions or
modify it.
I wrote a decorator to log taken by a method/function to complete it
execution and its working wel
Terry Reedy wrote
>
> On 2/9/2012 6:43 AM, Mateusz Loskot wrote:
>> import xyz print(xyz.flag) # OK
>> xyz.flag = 0 # error due to no write access
>
> Why prevent that? If you called it 'FLAG', that would indicate that it
> is a constant that should not be changed. While Python make some effor
jkn wrote:
> Hi Peter
>
> On Feb 9, 7:33 pm, Peter Otten <__pete...@web.de> wrote:
>> jkn wrote:
>> > is it possible to have multiple namespaces within a single python
>> > module?
>>
>> Unless you are abusing classes I don't think so.
>>
>> > I have a small app which is in three or four .py file
o.O
Very nice
On Fri, Feb 10, 2012 at 8:58 PM, Arnaud Delobelle wrote:
> On 10 February 2012 06:21, Ian Kelly wrote:
>> (3219 + 99) // 100 * 100
>>> 3300
>> (3289 + 99) // 100 * 100
>>> 3300
>> (328678 + 99) // 100 * 100
>>> 328700
>> (328 + 99) // 100 * 100
>>> 400
>>>
>>> Thos
On 8 February 2012 01:48, Lei Cheng wrote:
> Hi all,
>
> In a py file, when to use import statements in the header, when to use
> import statements in the blocks where they are used?
> What are the best practices?
> Thanks!
Aside from other answers: in some rare cases, importing within a
On 10 February 2012 00:05, Ethan Furman wrote:
> Ethan Furman wrote:
>>
>> Hrm -- and functions/classes/etc would have to refer to each other that
>> way as well inside the namespace... not sure I'm in love with that...
>
>
>
> Not sure I hate it, either. ;)
>
> Slightly more sophisticated code:
On 10/02/2012 10:10, sisifus wrote:
Hello all,
I new in python but i want to practice very much.
In interesting in build an application which read a text file, translate
the information in 128 bar code format and print all the information in a
printer.
File text content:
123456
123456
Where e
On 10 February 2012 03:27, Terry Reedy wrote:
> On 2/9/2012 8:04 PM, Steven D'Aprano wrote:
>
>> Python happily violates "consenting adults" all over the place. We have
>> properties, which can easily create read-only and write-once attributes.
>
>
> So propose that propery() work at module level,
Hello all,
I new in python but i want to practice very much.
In interesting in build an application which read a text file, translate
the information in 128 bar code format and print all the information in a
printer.
File text content:
123456
123456
Where each line mean:
1º --> Print in text fo
On Fri, Feb 10, 2012 at 1:30 PM, Nathan Rice
wrote:
> The only thing needed to avoid the hash collision is that your hash
> function is not not 100% predictable just by looking at the python
> source code. I don't see why every dict would have to be created
> differently. I would think having th
On 10 February 2012 06:21, Ian Kelly wrote:
> (3219 + 99) // 100 * 100
>> 3300
> (3289 + 99) // 100 * 100
>> 3300
> (328678 + 99) // 100 * 100
>> 328700
> (328 + 99) // 100 * 100
>> 400
>>
>> Those are all rounded up to the nearest 100 correctly.
>
> One thing to be aware of though
I prefer to decorate a function not a method.
I prefer to decorate an object to own a new method from the existed ones
inherited in all the class levels.
I do not decorate a class if not necessary.
I believe this is more pythonic to add functionalities to objects in classes by
aggregated
在 2012年2月4日星期六UTC+8上午8时27分56秒,Antti J Ylikoski写道:
> In Python textbooks that I have read, it is usually not mentioned that
> we can very easily program Common LISP-style closures with Python. It
> is done as follows:
>
> -
>
> # Make a Common LISP-like closure
Thanks a bunch for the whole team!
Best,
anonhung
On 2/9/12, eGenix Team: M.-A. Lemburg wrote:
>
> ANNOUNCEMENT
>
> mxODBC Zope Database Adapter
>
> Version 2.0.2
>
>
Thank you
On 2012/02/10, at 0:36, John Posner wrote:
> On 2:59 PM, Devin Jeanpierre wrote:
>
>
>> It is kind of funny that the docs don't ever explicitly say what a
>> property is. http://docs.python.org/library/functions.html#property --
>> Devin
>
> Here's a writeup that does:
> http://wiki
74 matches
Mail list logo