Hello,
I'm trying to intercept one or more methods in file-like objects (in
this particular case just sys.stdin really), essentially I need a
decorator/proxy implemented.
What's the idiomatic way to do this? Since file objects do not have a
base class(?), would I need to implement all methods to
On Thu, Feb 19, 2009 at 11:51 AM, Emile van Sebille wrote:
> Oxymoron wrote:
>>
>> I'm trying to intercept one or more methods in file-like objects
>
> Shadowing perhaps?
Neat stuff - but not applicable for me I think:
1. I receive the handle. I need this function i
Thanks for the answers everyone.
Denis, I wish to wrap an already open file handle basically, so simply
extending and overriding doesn't help - my proxy won't be instantiated
like a file, just used like one and if not intercepting I need to
delegate down to the proxied "real" handle. If I'm missin
Hello,
On Sat, Mar 7, 2009 at 11:03 AM, Harris, Sarah L
wrote:
> import zipfile, glob, os
> os.chdir('E:\\test1')
> from os.path import isfile
> fname=filter(isfile, glob.glob('*.zip'))
> for fname in fname:
> zipnames=filter(isfile, glob.glob('*.zip'))
> for zipname in zipnames:
>
I think you're looking for refactoring features, in this particular
case, a compose method/function refactor.
Generally, generic editors will have trouble doing this right since it
requires some inferencing capability on the selected code, your best
bet is probably googling Python-aware IDEs with
Hi,
On Wed, Apr 15, 2009 at 7:29 PM, mbikinyi brat wrote:
> Dear ALL,
> When you type a code in IDLE-Python, they appear in different colours.
> For instance:
> def factorial(n):
> if n==0:
> return 1
> else:
> recurse=factorial(n-1)
> result=n*recurse
> return result
> factorial in bl
Hi,
<>
On Wed, Apr 15, 2009 at 7:41 PM, mbikinyi brat wrote:
> Dear Oxymoron,
> In my previous example I had to import math for it to work . But in this
> code with the factorial, I have not imported anything yet when I call it
> with factorial(5), I get the result. How is
Hi,
On Wed, Apr 15, 2009 at 6:52 PM, mbikinyi brat wrote:
> Hi All,
> This is a code I have written to calculate the area of a circle.
> def area(radius):
> temp=math.pi*radius**2
> return temp
>
> I now call it by entering area(12) at the prompt in IDLE. This is the error
> message I get. Can
Hello,
On Thu, Apr 23, 2009 at 10:55 PM, spir wrote:
>
> My app is about parsing, which input and output usually both are big and
> complicated *strings*. So that I find the command line model really
> unappropriate for expressing test cases and their expected results.
>
Interesting - haven't r
(Sent to John only by mistake, now sending to list. Sorry John!)
On Tue, Aug 18, 2009 at 5:48 AM, Oxymoron wrote:
> Hi John,
>
> On Tue, Aug 18, 2009 at 4:31 AM, John wrote:
>>
>> I'd like to understand how python can integrate with Java in general and then
>>
(Posting to list!)
On Tue, Aug 18, 2009 at 6:01 AM, John wrote:
>
> First I love your handle. And second, thanks for taking the time to explain
:-)
> jython world. But I was really looking for a simple way of calling a report
> writer (like using a com object) to print a report. At this point
On Tue, Aug 18, 2009 at 8:50 AM, John wrote:
> I don't know enough about jython to understand what has to be done. Let's say
> I can write the code to retrieve the data in cPython. And I can write a
> module in jython that will accept the data passing it on to the report
> writer. How can I call
On Thu, Sep 24, 2009 at 10:15 PM, george fragos wrote:
> print format % (item_width, 'Cantaloupes', price_width, 1.92)
> print format % (item_width, 'Dried Apricots (16 gr)' price_width, 8)
>
Notice the line before (works) and after (doesn't work - as the interpreter
pointed out), how do you sepa
Hello,
On Sat, Oct 3, 2009 at 3:56 PM, Didar Hossain wrote:
> homedir = os.environ.get('HOME')
>
> if homedir:
>print "My home directory is %s" % homedir
>
>
> I do this in Perl -
>
> my $home;
>
> if ($home = $ENV{'HOME'}) { print "My home directory is $home\n"; }
>
> Can I do a similar shor
(Did not reply to list earlier, apologies)
On Sat, Oct 3, 2009 at 7:47 PM, Didar Hossain wrote:
> >>> There are probably various syntactic tricks to achieve the same,
> however,
> >>> the main reason you can't do it is that assignment in Python is a
> statement
> >>> rather than an expression, i.
Hello,
On Wed, Oct 7, 2009 at 6:57 AM, Christer Edwards
wrote:
>
> do something to x for each x in list, with an optional qualifier.
>
To be more precise:
http://docs.python.org/tutorial/datastructures.html#list-comprehensions
"Each list comprehension consists of an expression followed by a fo
Hello,
On Fri, Oct 9, 2009 at 6:54 PM, Stefan Lesicnik wrote:
> The issue in this case is that i need to check if the one value
> superseeds the other, and in that case, not print it out. I think the
> problem is that when you are in the loop, you dont know about the
> other object that you haven
On Fri, Oct 9, 2009 at 9:35 PM, Oxymoron wrote:
> Thus, you can muck around with x[i] (current item), and x[i+1] (next
> item), and decide how you want to proceed with the loop. Note the use
> of len(x) - 1 rather than just len(x) to easily prevent an IndexError
> or extra specia
On Fri, Oct 9, 2009 at 11:02 PM, Kent Johnson wrote:
> On Fri, Oct 9, 2009 at 3:54 AM, Stefan Lesicnik wrote:
>
> You can easily keep track of the previous item by assigning it to a
> variable. For example this shows just the increasing elements of a
> sequence:
>
> In [22]: items = [0, 1, 3, 2,
(Did not do a reply-all earlier)
On Sat, Oct 10, 2009 at 3:20 PM, xbmuncher wrote:
> Which piece of code will conserve more memory?
> I think that code #2 will because I close the file more often, thus freeing
> more memory by closing it.
> Am I right in this thinking... or does it not save me a
On Sun, Oct 11, 2009 at 4:07 AM, Rich Lovely wrote:
> for i, v in enumerate(x[:-1]): #omitting last value in list to avoid
> IndexError
> print v, x[i+1]
Thanks for the tip on enumerate, escaped me. Much like Kent's simply
using a temporary var escaped me despite having done similar things
of
21 matches
Mail list logo