On May 6, 2:36 am, Jabba Laci wrote:
> Hi,
>
> If I want to check if a list is empty, which is the more pythonic way?
>
> li = []
>
> (1) if len(li) == 0:
> ...
> or
> (2) if not li:
> ...
>
> Thanks,
>
> Laszlo
is there any problem with
(3) if li == []:
?
Seems to work when I test it and seem
On May 6, 8:25 am, Christian Heimes wrote:
> Am 06.05.2011 14:09, schrieb scattered:
>
> > sets could also work
>
> > if set('abc') & set(line) == set():
> > print line
>
> Right!
> Sets work in this special case, because the OP just want
On May 6, 7:00 am, Christian Heimes wrote:
> Am 06.05.2011 12:47, schrieb Lutfi Oduncuoglu:
>
> > Hi,
>
> > I am trying to write a script and I realised that I need to use something
> > like
>
> > if ('a' or 'b' or 'c') not in line:
> > print line
>
> > But it does not work for. What may be th
On May 4, 12:51 pm, Daniel Neilson wrote:
> Hello,
> I'm hoping that there will be someone here with sufficient expertise
> to answer a question on Python 3 for me.
>
> I work in the Computer Science department at a large Canadian
> University. We are currently doing a feasibility analysis for
On Apr 22, 6:57 am, Jean-Michel Pichavant
wrote:
> Shafique, M. (UNU-MERIT) wrote:
> > Hi,
> > I have a number of different groups g1, g2, … g100 in my data. Each
> > group is comprised of a known but different set of members (m1, m2,
> > …m1000) from the population. The data has been organized in
On Apr 12, 10:05 am, Westley Martínez wrote:
> On Tue, 2011-04-12 at 12:44 +1000, Chris Angelico wrote:
> > On Tue, Apr 12, 2011 at 12:20 PM, James Mills
> > wrote:
> > > On Tue, Apr 12, 2011 at 12:18 PM, Jason Swails
> > > wrote:
> > >> This is only true if n < 5. Otherwise, the first returns
On Apr 12, 2:21 am, James Mills wrote:
> On Tue, Apr 12, 2011 at 4:08 PM, Nobody wrote:
> > It should be abundantly clear that this only returns if the expression is
> > considered true, otherwise it continues on to the following statements.
>
> Uggh come on guys. We've been over this.
> You cann
On Apr 6, 4:48 am, Glazner wrote:
> > > def invert(p):
> > > inverse = [None] * len(p)
> > > for (i, j) in enumerate(p):
> > > inverse[j] = i
> > > return inverse
>
> > Elegant. This seems like the best solution, although it isn't as much
> > fun to write as a "one-liner". Than
On Apr 5, 5:46 pm, Ian Kelly wrote:
> On Tue, Apr 5, 2011 at 3:17 PM, scattered wrote:
> > Greetings,
>
> > I've been playing around (in Python 3.1) with permutations of
> > 0,1,...,n-1, represented by lists, p, of length n, where p[i] = the
> > image of i un
Greetings,
I've been playing around (in Python 3.1) with permutations of
0,1,...,n-1, represented by lists, p, of length n, where p[i] = the
image of i under the permutation. I wanted to be able to calculate the
inverse of such a permutation, and came up with the following succint
but not quite re
On Mar 25, 1:44 am, Steven D'Aprano wrote:
>
> In my earlier post, I described the dynamic creation of variables as:
>
> "... something you should *nearly* always avoid doing." [Emphasis added.]
>
> Congratulations, you've found one of the few exceptions. Of course an
> interactive shell must allo
On Mar 24, 11:08 pm, Tim Leslie wrote:
> On 25 March 2011 13:51, scattered wrote:
>
> > Here is another possibility: you are using Python *interactively* in
> > solving cryptograms (as a matter of fact - I was doing exactly this
> > yesterday in trying to solve some Playf
On Mar 24, 10:51 pm, scattered wrote:
[snip]
> I can easily imagine other
> situations in which a user might want to create a large number of
> bindings for interactive use. Maybe as a teacher (I'm a math teacher)
> you have written a student-class which contains thing
On Mar 24, 7:18 pm, Steven D'Aprano wrote:
> On Thu, 24 Mar 2011 14:39:34 -0700, scattered wrote:
> > Could try:
>
> >>>> my_list = [("x", 7), ("y", 8)]
> >>>> for pair in my_list: exec(pair[0] + " = " + str(pair[1]))
On Mar 24, 2:39 pm, Seldon wrote:
> Hi, I have a question about generating variable assignments dynamically.
>
> I have a list of 2-tuples like this
>
> (
> (var1, value1),
> (var2, value2),
> .. ,
> )
>
> where var1, var2, ecc. are strings and value1, value2 are generic objects.
>
> Now, I would
On Mar 15, 4:58 pm, davidj411 wrote:
> it seems that if I copy the python.exe binary and the folders
> associated with it to a server without python, i can run python.
> does anyone know which files are important to copy and which can be
> omitted?
>
> i know about py2exe and have had no luck with
On Mar 10, 12:47 am, Sunjay Varma wrote:
> For some reason, sub-classing and overwriting a built-in type does not
> change the behavior of the literal. Logically speaking, overwriting a
> name, such as str, should delete the basic str type, and replace it
> with the new class or object put in its
On Feb 23, 5:22 pm, grobs456
wrote:
> Hi,
>
> I am trying to work through the tutorial at:http://docs.python.org/tutorial/
>
> The issue I am facing is with regards to the discussion about
> "Invoking the Interpreter" and "Executable Python Scripts". It was
> rather hazy in my opinion.
>
> see:htt
On Dec 22, 11:40 am, William Gill wrote:
> I am teaching an 11 year old who wants to learn programming. I chose
> Python, and it is working well. I seem to remember lots of simple
> script games, like quizzes, number games etc. that would be good for his
> tutorial. However, now all I can find
On Nov 22, 9:45 am, Raffael Cavallaro
wrote:
> On 2010-11-22 08:12:27 -0500, markhanif...@gmail.com said:
>
> > All opinions are biased.
>
> All opinions show some bias. Not all opinions represent what is usually
> called a "conflict of interest." Since JH makes his living selling
> tools and trai
with
Excel. For now I think I will stick to my goal of learning things like
Chaco and wxPython. If I ever take the Linux plunge it's nice to know
that OpenOffice is closing the gap with Excel as far as programmability
is concerned.
-scattered
--
http://mail.python.org/mailman/listinfo/python-list
ke statistical simulations. I liked the ability to get functioning
code quickly in VBA, together with the ability to easily generate
graphs of the results, etc., but I finally got tired of the slow speed
and verbose syntax. I'm hoping that Python (as packaged by Enthought
together with variou
22 matches
Mail list logo