I have a problem with understanding how lists, strings, tuples, number
types and input arguments all interact with each other.
I have this program, in which I can use the *a structure to input
unlimited arguments.
As an example, if I use three arguments, it looks like this:
def main():
#Play a
WM. wrote:
# The natural numbers(natnum), under 1000, divisible by 3 or by 5 are
to be added together.
natnum = 0
num3 = 0
num5 = 0
cume = 0
# The 'and' is the 15 filter; the 'or' is the 3 or 5 filter.
while natnum <= 999:
num3 = natnum/3
num5 = natnum/5
if natnum - (num3 * 3) == 0 a
2009/1/13 Judith Flores :
> Hello,
Hi Judith,
> 1. When I run the code above for the first time, the contents of the
> pre-existing file disappear, if I
> run the script a second time, now I can see the value of x.
This is a consequence of this line:
> outfile=open('template.csv','w') # Th
"Judith Flores" wrote
I have been struggling a while trying to figure out how to modify
a csv
file using the csv.DictWriter class. Let's suppose I have the
following code:
I have never used DictWriter but...
outfile=open('template.csv','w') # This is a pre-existing file
Opening a
Hello,
I have been struggling a while trying to figure out how to modify a csv file
using the csv.DictWriter class. Let's suppose I have the following code:
import csv
outfile=open('template.csv','w') # This is a pre-existing file that
contains 3 variables (3 columns). The variables will
On Mon, Jan 12, 2009 at 5:23 PM, WM. wrote:
> # The natural numbers(natnum), under 1000, divisible by 3 or by 5 are to be
> added together.
> natnum = 0
> num3 = 0
> num5 = 0
> cume = 0
> # The 'and' is the 15 filter; the 'or' is the 3 or 5 filter.
> while natnum <= 999:
>num3 = natnum/3
>
You know, that's a great idea :-) Just using options I could keep my initial
checks the same (e.g. making sure needed options were included by looking at
options.foo) and pass it along without adding much to the query function.
Thanks!
___
Samuel Huckins
Homepage - http:
# The natural numbers(natnum), under 1000, divisible by 3 or by 5 are to
be added together.
natnum = 0
num3 = 0
num5 = 0
cume = 0
# The 'and' is the 15 filter; the 'or' is the 3 or 5 filter.
while natnum <= 999:
num3 = natnum/3
num5 = natnum/5
if natnum - (num3 * 3) == 0 and natnum -
On Mon, Jan 12, 2009 at 4:39 PM, wormwood_3 wrote:
> Hello all,
>
> I have used *args and **kwargs to have a function accept optional
> parameters, but is there a lazy way to optionally pass parameters? For
> example, say my script can accept a number of parameters for a database
> connection, suc
A small correction to my code, although the point was hopefully still clear:
if options.user:
do_mysql_query(options.user)
else:
do_mysql_query()
From: wormwood_3
To: Python Tutorlist
Sent: Monday, January 12, 2009 4:39:30 PM
Subject: [Tutor] Optiona
Hello all,
I have used *args and **kwargs to have a function accept optional parameters,
but is there a lazy way to optionally pass parameters? For example, say my
script can accept a number of parameters for a database connection, such as
user, password, and database name. The function that ma
"Alan Gauld" wrote in message
news:50c11a8b9db748fa9e6e892067cce...@xp...
I've managed to do something incredibly stupid on my XP box.
I've created a folder that is a link to itself - at least I think that's
what has
happened, it was a CASE tool that I was using that actually did the
damage.
On Mon, Jan 12, 2009 at 2:07 PM, Alan Gauld wrote:
> I've managed to do something incredibly stupid on my XP box.
> I've created a folder that is a link to itself - at least I think that's
> what has
> happened, it was a CASE tool that I was using that actually did the damage.
Try exploring the o
> From: "Alan Gauld"
> Date: Mon, 12 Jan 2009 19:07:23 -
> Subject: [Tutor] Deleting recursive folder definition
> I've managed to do something incredibly stupid on my XP box.
> I've created a folder that is a link to itself - at least I think that's what
> has
> happened, it was a CASE tool
did you try "rd /s /q" from the root directory command prompt?
-L
On Jan 12, 2009, at 11:07 AM, Alan Gauld wrote:
I've managed to do something incredibly stupid on my XP box.
I've created a folder that is a link to itself - at least I think
that's what has
happened, it was a CASE tool that I
I've managed to do something incredibly stupid on my XP box.
I've created a folder that is a link to itself - at least I think
that's what has
happened, it was a CASE tool that I was using that actually did the
damage.
The symptoms are that I can "infinitely" navigate down to the next
level.
On Mon, Jan 12, 2009 at 12:21 PM, bob gailer wrote:
> Noufal Ibrahim wrote:
>>
>> Hello everyone,
>> What is the pythonic way of selecting the first element of a list
>> matching some condition?
>> I often end up using
>>
>> [x for x in lst if cond(x)][0]
>>
>> This looks b
> 1) itertools.dropwhile(cond, lst) will return a list with the desired element
> first.
i think in order to use this, the OP needs to invert his Boolean logic
because it *drops* elements while the conditional is True. as soon as
it hits False the 1st time, all remaining elements (including the o
Noufal Ibrahim wrote:
Hello everyone,
What is the pythonic way of selecting the first element of a
list matching some condition?
I often end up using
[x for x in lst if cond(x)][0]
This looks bad and raises IndexError if nothing is found which
is ugly too.
1) i
Hello everyone,
What is the pythonic was of selecting the first element of a
list matching some condition?
I often end up using
[x for x in lst if cond(x)][0]
This looks bad and raises IndexError if nothing is found which
is ugly too.
Thanks.
--
~noufal
http://ni
"Marco Petersen" wrote
> This was the line of code:
>
> $ 2to3 testscript.py
But I suspect...
this will run your default python interpreter which is likely to still
be your 2.5 version. THe convertion scrpt is almost certainly 3.0.
So I think you will need to explicitly call the interpreter:
On Mon, Jan 12, 2009 at 3:56 AM, Alan Gauld wrote:
> "Marco Petersen" wrote
>> This was the line of code:
>>
>> $ 2to3 testscript.py
>
> But I suspect...
> this will run your default python interpreter which is likely to still
> be your 2.5 version. THe convertion scrpt is almost certainly 3.0.
Title: Signature.html
Thanks. Is it possible to just disable the vanilla version? I may want
to switch between the two. Most users of the program I'm about to
modify use the vanilla version. At some point, I may want to go back to
it to verify that in their world all is OK.
Alan Gauld wrote:
"Marco Petersen" wrote
I have Python 3.0. I tried to use the 2to3 program included with the
interpreter to convert some scripts for Python 2.5 to Python 3.0
ones.
When I try to start it form the Python command line, it says it is a
syntax error.
Its always best to send us an actual cut n
"Wayne Watson" wrote
I installed "Python" 2.5 a few months ago, and decided I'd like to
try
windowpy from ActiveState. Is having both of these installed going
to
cause me trouble?
Multiple versions of Python should not be a problem provided you put
them in different folders.
C:\python25
25 matches
Mail list logo