You can do it more concise.
>>> def isListOrString(p):
...return any((isinstance(p,list),isinstance(p,str)))
...
>>> listOrString("string")
True
>>> listOrString([1,2,3])
True
>>> listOrString(2)
False
>>> listOrString(False)
False
Rainer
--
http://mail.python.org/mailman/listinfo/python-lis
Hello,
> try:
> songs = [Song(id) for id in song_ids]
> except Song.DoesNotExist:
> print "unknown song id (%d)" % id
that's is a bad programming style. So it will be forbidden with python 3. The
reason is that list comprehension is a construct from the functional world.
Am Samstag, 16. Juli 2011 08:46:42 UTC+2 schrieb Steven D'Aprano:
> Rainer Grimm wrote:
>
> > I think it's relatively difficult to get a feeling what a are the key
> > points behind functional programming. So I think you should start
> > explaining the concept
Hello,
> > (My post did not appear in the mailing list, so this is my second try.
> > Apology if it ends up posted twice)
> >
> > Hi, all,
> >
> > If you have read my previous posts to the group, you probably have some
> > idea why I asked this question.
> >
> > I am giving a few presentations
Hallo,
you can also look at list comprehension as syntactic sugar for the
functions map and filter. The two functions from the functional world
can be expressed in a comprehensive way with list comprehension.
>>> [x**2 for x in range(10) ] == map ( lambda x: x*x, range(10))
True
>>> [ x for x in ra
On Dec 31 2009, 5:13 pm, davidj411 wrote:
> I am not sure why this behavior is this way.
> at beginning of script, i want to create a bunch of empty lists and
> use each one for its own purpose.
> however, updating one list seems to update the others.
>
> >>> a = b = c = []
> >>> a.append('1')
> >
On Sep 18, 5:42 pm, Paul Rubin <http://phr...@nospam.invalid> wrote:
> Rainer Grimm writes:
> > have a look at valgrind.
>
> Have you actually used that on Python?
Not with python as far I can remember. But often with C++ executables,
as i mentioned it.
I you look at
htt
On 17 Sep., 02:10, Matthew Wilson wrote:
> I have a web app based on TurboGears 1.0. In the last few days, as
> traffic and usage has picked up, I noticed that the app went from using
> 4% of my total memory all the way up to 50%.
>
> I suspect I'm loading data from the database and somehow preve
Hallo Alan,
> def apply2(itr, methodname, *args, **kwargs):
> f = operator.methodcaller(methodname, *args, **kwargs)
> for item in itr:
> f(item)
you can do it in a functional way.
>>> class A(object):
... def hello(self): return "hello: " + str
( self.__class__.__name__ )
...
>>
ts => strategy
pattern
override the steps of the processing in subclasses => template method
Regards,
Rainer
--
_creating IT solutions
Rainer Grimm
scVENUS Schulungsleiter science + computing ag
phone +49(0)7071 9457-253
ce wrote:
> Hi,
>
> My company is using python currently for our website. We need to
> develop a GUI front-end for our ERP that would be portable (Windows
> and Linux).
>
> My question is which solution would be better for the GUI (and easier
> to implement)? I knew there are something like wxidg
11 matches
Mail list logo