> My current dilemma is that I've got a program that takes one argument
> and needs to be run multiple times with this argument being validated
> based on the previous one. So proper usage might be
> myprog red
> myprog blue
> myprog green
> where it would be wrong to do
>
Sorry for jumping in to this a little late, but...
> This is (IMO) more elegant:
> def neverEndingStatus():
> index = 0
> statusChars = ['|', '\\', '-', '/']
> while True:
> yield statusChars[index]
> index = (index + 1) % 4
Why not go a step further?
def neverEn
Kent Johnson wrote:
If you mean for j to be a list of foobar(item) then use
j=[foobar(item) for item in x]
The first part of the list comp can be any valid expression.
Does that mean that there are invalid expressions? I'd enjoy seeing an
example.
I suppose if it's an expression, it must be valid,
Juan Shen wrote:
> Binary integer is extremely useful in my
> electronic-related job. So...I need help. Is there any function to
> transform between binary and decimal integers in python's library? If
> not, what's the solution to binary?
I can't speak for everyone, but most of the people I've met
Juan Shen wrote:
def is_leap_year(year):
is_leap = True
try:
datetime.date(year, 2, 29)
except ValueError:
is_leap = False
return is_leap
I would write
def is_leap_year(year):
try:
datetime.date(year, 2, 29)
return True
except ValueError: