At first I was going to post the following:
I just discovered the inspect module, which contains the isfunction and
ismethod functions. For some reason, I used to be under the impression
that Python methods are no different from Python functions. Naturally,
I wondered why both of these needed to
[EMAIL PROTECTED] wrote:
> Hey there,
> i have been learning python for the past few months, but i can seem to
> get what exactly a lamda is for. What would i use a lamda for that i
> could not or would not use a def for ? Is there a notable difference ?
> I only ask because i see it in code sample
Bruno Desthuilliers wrote:
> danielx wrote:
> > At first I was going to post the following:
> >
> >
> >
> (snip)
> >
> >
> >
> > but then I tried this:
> >
> >
> >>>>res = Foo.__dict__['func']
> >>
Leif K-Brooks wrote:
> danielx wrote:
> > This is still a little bit of magic, which gets me thinking again about
> > the stuff I self-censored. Since the dot syntax does something special
> > and unexpected in my case, why not use some more dot-magic to implement
> &g
Duncan Booth wrote:
> danielx wrote:
>
> >>>> Foo.func = dan# <-- Appearantly, something magical happens here,
> because...
> >>>> Foo.func
> >
> >>>> f = Foo.func
> >>>> f is dan # <-- things beg
Bruno Desthuilliers wrote:
> ZeD wrote:
> > Bruno Desthuilliers wrote:
> >
> >
> >>>I decided to change the name of an attribute. Problem is I've used the
> >>>attribute in several places spanning thousands of lines of code. If I
> >>>had encapsulated the attribute via an accessor, I wouldn't need
Bruno Desthuilliers wrote:
> danielx wrote:
> (snip)
>
> > Python's lambda really can't be as powerful as Lisp's because Python
> > does not have expressions that do case analysis (this is not lambda's
> > fault, of course ;). The reason is that you
Bruno Desthuilliers wrote:
> danielx wrote:
> > Bruno Desthuilliers wrote:
> >
> >>danielx wrote:
>
> (snip)
> >>>which gets me thinking again about
> >>>the stuff I self-censored. Since the dot syntax does something special
> >>&
Boris Borcic wrote:
> does
>
> x.sort(cmp = lambda x,y : cmp(random.random(),0.5))
>
> pick a random shuffle of x with uniform distribution ?
>
> Intuitively, assuming list.sort() does a minimal number of comparisons to
> achieve the sort, I'd say the answer is yes. But I don't feel quite
> confor
David G. Wonnacott wrote:
> From: "danielx" <[EMAIL PROTECTED]>
>Date: 22 Jul 2006 01:43:30 -0700
>
>Boris Borcic wrote:
>> does
>>
>> x.sort(cmp = lambda x,y : cmp(random.random(),0.5))
>>
>> pick a random shu
Bruno Desthuilliers wrote:
> danielx wrote:
> > Bruno Desthuilliers wrote:
> >
> >>danielx wrote:
> >>
> (snip)
> >>>
> >>>Obviously, such things would be omitted from your docs, but users also
> >>>learn by interacti
Gerhard Fiedler wrote:
> On 2006-07-20 18:10:21, danielx wrote:
>
> >>> When supporting documents aren't sufficient to learn an api (I'm sure
> >>> this never happens, so just humor me), you can always turn to
> >>> interactive Python.
>
fuzzylollipop wrote:
> danielx wrote:
> > Bruno Desthuilliers wrote:
> > > danielx wrote:
> > > > At first I was going to post the following:
> > > >
> > > >
> > > >
> > > (snip)
> > > >
> > &
Bruno Desthuilliers wrote:
> danielx a écrit :
> > Bruno Desthuilliers wrote:
> >
> >>danielx wrote:
> >>
> >>>Bruno Desthuilliers wrote:
> >>>
> >>>
> >>>>danielx wrote:
> >>>>
> >>
&
Bruno Desthuilliers wrote:
> Antoon Pardon wrote:
> > On 2006-07-21, fuzzylollipop <[EMAIL PROTECTED]> wrote:
> >
> >>danielx wrote:
> >>
> (snip)
> >>
> >>
> >>if you prefix with a single underscore, that tells the use
W. D. Allen wrote:
> I want to write a retirement financial estimating program. Python was
> suggested as the easiest language to use on Linux. I have some experience
> programming in Basic but not in Python.
>
> I have two questions:
> 1. What do I need to be able to make user GUIs for the progra
Bruno Desthuilliers wrote:
> Josiah Manson a écrit :
> > I found that I was repeating the same couple of lines over and over in
> > a function and decided to split those lines into a nested function
> > after copying one too many minor changes all over. The only problem is
> > that my little helper
Gerhard Fiedler wrote:
> On 2006-07-23 14:53:33, danielx wrote:
>
> > I can't figure out why Josiah's breakLine function won't work either. I
> > know Josiah has had his problem resolved, but I'd still like to know
> > why his func won't w
Bruno Desthuilliers wrote:
> Gerhard Fiedler wrote:
> > On 2006-07-25 04:06:24, Steve Holden wrote:
> >
> >
> >>Dennis Lee Bieber wrote:
> >>
> >>>On Mon, 24 Jul 2006 17:35:50 -0300, Gerhard Fiedler <[EMAIL PROTECTED]>
> >>>declaimed the following in comp.lang.python:
> >>>
> >>>
> It is surpr
[EMAIL PROTECTED] wrote:
> Here is my script:
>
> from mechanize import *
> from BeautifulSoup import *
> import StringIO
> b = Browser()
> f = b.open("http://www.translate.ru/text.asp?lang=ru";)
> b.select_form(nr=0)
> b["source"] = "hello python"
> html = b.submit().get_data()
> soup = BeautifulS
Gerhard Fiedler wrote:
> On 2006-07-30 09:54:14, Antoon Pardon wrote:
>
> > Aren't you looking too much at implementation details now?
>
> Possibly, but at this point I'm still trying to understand how Python does
> these things, and what the useful abstraction level is for me. I also still
> have
OriginalBrownster wrote:
> I am using a class called UploadedFile.
> I want to create a for loop to itterate through the objects within file
> name
>
> class UploadedFile(SQLObject):
> filename = StringCol(alternateID=True)
> abspath = StringCol()
> uniqueid = IntCol()
>
> I'll sh
I'm surprised no one has mentioned neat-er, more pythonic ways of doing
this. I'm also surprised no one mentioned regular expressions. Regular
expressions are really powerful for searching and manipulating text.
Here is where I learned most of the stuff I know about regular
expressions:
http://www
Gerhard Fiedler wrote:
> On 2006-08-05 09:30:59, Antoon Pardon wrote:
>
> >> But this means that C variables are not analog to Python variables,
> >> [...]
> >
> > Yes they are.
>
> Nobody so far has been able to create a simple table with analog operations
> Python vs C that operates on C /variabl
No offense. I didn't mean there was anything wrong with your way, just
that it wasn't "neat". By that, I meant, you were still using lots of
for loops and if blocks.
Justin Azoff wrote:
> danielx wrote:
> > I'm surprised no one has mentioned neat-er, more py
Is there an equivalent in windows?
Jon wrote:
> Perhaps using os you could work with lsof
> [http://www.linuxcommand.org/man_pages/lsof8.html]
>
> Jon
>
> Thomas Bartkus wrote:
> > This may be more of a Linux question, but I'm doing this from Python. .
> >
> > How can I know if anything (I don
len wrote:
> Hi all
>
> I have a file that I receive from another party which is basicly a csv
> file containing the following type of information;
Python has a csv module. I'm not sure if you're already using that or
if it would be useful to you:
http://docs.python.org/lib/module-csv.html
>
> T
Is your declaration of ABC supposed to have some_super as one of the
base classes? Your constructor has some_super as a parameter. What is
this supposed to mean in light of the declaration for ABC?
If you are trying to customize the base class of ABC by passing an
argument to the constructor of AB
Jackson wrote:
> Thanks for the reply.
>
> danielx wrote the following on 2006-08-13 19:49:
> > Is your declaration of ABC supposed to have some_super as one of the
> > base classes? Your constructor has some_super as a parameter. What is
> > this supposed to mean in l
Jackson wrote:
> Maric Michaud wrote the following on 2006-08-14 01:26:
> > In [28]: class Animal(object) :
> >: _types = {}
> >:
> >:
> >
> > In [29]: class Worker(object) :
> >: def work(self) : print 'hard'
> >:
> >:
> >
> [snip]
> > What
KraftDiner wrote:
> I have a class that is defined in a file called MyClass.py
>
> How do I use that class in another python script..
> import MyClass ? (Does it need to be in a specific location?)
MyClass.py has to be on your "python path". Your python path is a list
of directories python will
Fuzzyman wrote:
> Bayazee wrote:
> > hi
> > can we hide a python code ?
> > if i want to write a commercial software can i hide my source code from
> > users access ?
> > we can conver it to pyc but this file can decompiled ... so ...!!
> > do you have any idea about this ...?
> >
> > -
Steven D'Aprano wrote:
> On Tue, 15 Aug 2006 09:00:16 -0700, Ben Sizer wrote:
>
> > Yes, in much the same way that there is no point ever locking your
> > doors or installing burglar alarms, as a determined thief will
> > eventually steal your belongings.
>
> That's an utterly pointless and foolish
Steven D'Aprano wrote:
> On Wed, 16 Aug 2006 13:39:10 -0700, danielx wrote:
>
> > Steven D'Aprano wrote:
> >> On Tue, 15 Aug 2006 09:00:16 -0700, Ben Sizer wrote:
> >>
> >> > Yes, in much the same way that there is no point ever locking
Paul Boddie wrote:
> danielx wrote:
> >
> > But we have only considered the economics of such a decision. Even if
> > there is no market value to a work, a person has an understandable
> > desire to exercise the rights of ownership over a work, given the
> >
Mark E. Fenner wrote:
> Mark E. Fenner wrote:
>
> > John Machin wrote:
> >
> >>
> >> Mark E. Fenner wrote:
> >>
> >>> Here's my class of the objects being copied:
> >>
> >> Here's a couple of things that might help speed up your __init__
> >> method, and hence your copy method:
> >>
> >>>
> >>> cl
Mark E. Fenner wrote:
> Paul McGuire wrote:
>
> > "Mark E. Fenner" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> >> Hello all,
> >>
> >
> >>
> >> Here's my class of the objects being copied:
> >>
> >> class Rule(list):
> >> def __init__(self, lhs=None, rhs=None, nClasses=0,
I would really like to highlight something Tal has already said: Python
strings are immutable. That means if you construct a string object, you
don't have to worry about someone else going in and changing that
object. What might happen, however, is that someone might reassign a
variable you have wh
On Oct 10, 12:28 pm, Paul Hankin <[EMAIL PROTECTED]> wrote:
> On Oct 10, 7:41 pm, wink <[EMAIL PROTECTED]> wrote:
>
> > I would like to know what would be considered the most
> > Pythonic way of handling errors when dealing with files,
> > solutions that seem reasonable using 2.5:
>
> The best way
Is there a convention for how to document function (or method)
parameters in doc strings? Recently, I've been doing alot of PHP
programming, and in PHPdoc, you'd do it like this:
/*
* @param type $foo Description.
*
* @return type Description.
*/
function bar($foo) {
...
}
Is there an equiv
On Feb 8, 2:49 am, Jean-Michel Pichavant
wrote:
> danielx wrote:
> > Is there aconventionfor how to document function (or method)
> > parameters in doc strings? Recently, I've been doing alot of PHP
> > programming, and in PHPdoc, you'd do it like this:
&
41 matches
Mail list logo