Re: [Tutor] Variables

2016-08-03 Thread Joaquin Alzola
>I'm trying to write a program w/ python that runs once a day and every time it >does it adds 20 to a variable. How do I do this so it doesn't reset the >variable to the original value every time I run it? You can output the value to a file? Then re-read the file once a day and assign that val

Re: [Tutor] Variables

2016-08-02 Thread Martin A. Brown
Hello Palmer, >> I'm trying to write a program w/ python that runs once a day and every time >> it does it adds 20 to a variable. How do I do this so it doesn't reset the >> variable to the original value every time I run it? > >You have to read the variable from a file saved to disk, add 20, >t

Re: [Tutor] Variables

2016-08-02 Thread Joaquin Alzola
>Also, lookup cron. It will start your program at a certain time you select, >every day Linux system "crontab -l" to edit it "crontab -e" Any doubts "man crontab" This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose

Re: [Tutor] Variables

2016-08-02 Thread Joel Goldstick
On Mon, Aug 1, 2016 at 10:15 PM, Steven D'Aprano wrote: > On Mon, Aug 01, 2016 at 01:26:19PM -0600, Palmer Gutke wrote: >> I'm trying to write a program w/ python that runs once a day and every time >> it does it adds 20 to a variable. How do I do this so it doesn't reset the >> variable to the or

Re: [Tutor] Variables

2016-08-01 Thread Steven D'Aprano
On Mon, Aug 01, 2016 at 01:26:19PM -0600, Palmer Gutke wrote: > I'm trying to write a program w/ python that runs once a day and every time > it does it adds 20 to a variable. How do I do this so it doesn't reset the > variable to the original value every time I run it? You have to read the variab

Re: [Tutor] Variables in email addresses

2015-06-17 Thread Joel Goldstick
On Wed, Jun 17, 2015 at 7:04 AM, Laura Creighton wrote: > In a message of Wed, 17 Jun 2015 02:05:49 +0100, Oliver Mercer-Deadman writes: >>Hi I am a complete newbie but am hoping to learn some python for a >>particular project. Before I hurl myself in I would like to know if a key >>element is goi

Re: [Tutor] Variables in email addresses

2015-06-17 Thread Laura Creighton
In a message of Wed, 17 Jun 2015 02:05:49 +0100, Oliver Mercer-Deadman writes: >Hi I am a complete newbie but am hoping to learn some python for a >particular project. Before I hurl myself in I would like to know if a key >element is going to be possible. > >I will need to be able to use a variable

Re: [Tutor] Variables (with lists??)

2011-11-22 Thread delegbede
Hi Chris, Straight to the point, this is how to populate a python dictionary. customer = {} This statement makes a new dictionary, which is empty though, called customer. A python dictionary has a pair of key and value linked with semicolon and seperated from other pairs by a comma. print

Re: [Tutor] Variables (with lists??)

2011-11-22 Thread Andreas Perstinger
On 2011-11-23 05:15, Chris Kavanagh wrote: I was going over one of Derek Banas' tutorials on youtube, and came across something I hadn't seen before. A variable with a list beside it (see code below). He sets the variable, customer , equal to a dict. Then uses the variable with ['firstname'],['la

Re: [Tutor] Variables and constants [was Re: working with strings inpython3]

2011-04-19 Thread Steven D'Aprano
bod...@googlemail.com wrote: And presumably cleans up the leftover object with the value of 42 when it changes to point at the 43 object? In principle, yes, the garbage collector will destroy the no-longer used object 42 once nothing is pointing to it any more. But in practice, Python cache

Re: [Tutor] Variables and constants [was Re: working with strings inpython3]

2011-04-19 Thread Steven D'Aprano
Joel Goldstick wrote: If a value has no name bound to it, python figures that out and destroys it Not quite... if there is no name, or any other reference, then the garbage collector will destroy it. But it doesn't have to be a name: anonymous objects can live inside lists, or dicts, or sets

Re: [Tutor] Variables and constants [was Re: working with strings inpython3]

2011-04-19 Thread Marc Tompkins
On Tue, Apr 19, 2011 at 2:37 PM, Joel Goldstick wrote: > > On Tue, Apr 19, 2011 at 3:32 PM, wrote: > >> And presumably cleans up the leftover object with the value of 42 when it >> changes to point at the 43 object? >> >> Or does it leave all changes in memory until the program exits? >> > > If a

Re: [Tutor] Variables and constants [was Re: working with strings inpython3]

2011-04-19 Thread Joel Goldstick
On Tue, Apr 19, 2011 at 3:32 PM, wrote: > And presumably cleans up the leftover object with the value of 42 when it > changes to point at the 43 object? > > Or does it leave all changes in memory until the program exits? > > Bodsda. > Sorry for top posting, my phone won't let me change it > Sent

Re: [Tutor] Variables and constants [was Re: working with strings inpython3]

2011-04-19 Thread bodsda
And presumably cleans up the leftover object with the value of 42 when it changes to point at the 43 object? Or does it leave all changes in memory until the program exits? Bodsda. Sorry for top posting, my phone won't let me change it Sent from my BlackBerry® wireless device -Original Me

Re: [Tutor] variables question.

2010-11-12 Thread Jeff Honey
Steven D'Aprano, et al, Thanks everyone for the thorough explanations on variable use and scope in Python. It was enlightening...and sometimes confusing, but I'm working on that. It just points out all the new things I have yet to learn about the language. -- ¤¤ ¤ kyoboku kazeo

Re: [Tutor] variables question.

2010-11-11 Thread Steven D'Aprano
Jeff Honey wrote: I have a question about where variables are exposed in python. I have a monolothic script with a number of functions defined, can those functions share variables? can I instantiate them outside the function of where they are needed? do they need to be wrapped in quotes, ever?

Re: [Tutor] variables question.

2010-11-10 Thread Luke Paireepinart
It's pretty typical for scoping rules. If you define variables outside of your funcs you can access them inside the func. If you want to change the value in the function you need to declare the scope as global. If you make another variable with the same name inside of a function it will shadow t

Re: [Tutor] variables question.

2010-11-10 Thread Emile van Sebille
On 11/10/2010 10:21 AM Jeff Honey said... I have a question about where variables are exposed in python. You're looking for scoping rules -- see for example http://stackoverflow.com/questions/291978/short-description-of-python-scoping-rules where they get into some detail, but the short and o

Re: [Tutor] variables question.

2010-11-10 Thread Alan Gauld
"Jeff Honey" wrote I have a question about where variables are exposed in python. Take a look at the namespaces topic in my tutor for more details but... I have a monolothic script with a number of functions defined, can those functions share variables? Yes but its usually bad practice

Re: [Tutor] Variables and Functions

2007-11-30 Thread Ricardo Aráoz
Alan Gauld wrote: > "Devon MacIntyre" <[EMAIL PROTECTED]> wrote > >> input their own numbers to fill in the board. My problem is that I >> can't get >> the variables 'puzzle' and 'new_puzzle' into that function (to be >> compared) >> because they are not globally defined; only in 'new_sudoku' >

Re: [Tutor] Variables and Functions

2007-11-29 Thread Alan Gauld
"Devon MacIntyre" <[EMAIL PROTECTED]> wrote > input their own numbers to fill in the board. My problem is that I > can't get > the variables 'puzzle' and 'new_puzzle' into that function (to be > compared) > because they are not globally defined; only in 'new_sudoku' > function. Here's > some se

Re: [Tutor] Variables and Functions

2007-11-28 Thread Michael H. Goldwasser
Hello Devon, Here's a quick [untested] push in the direction of taking the code you gave below and modeling it as a class using an object-oriented design. With this code, you could then create an instance of a puzzle as: toughOne = Sudoku() toughOne.play_game() Within

Re: [Tutor] Variables and Functions

2007-11-28 Thread Tiger12506
when we say you can put all of your functions in a class and use a class variable (in this case... self.puzzle) - Original Message - From: "Devon MacIntyre" <[EMAIL PROTECTED]> To: "Kent Johnson" <[EMAIL PROTECTED]> Cc: Sent: Wednesday, November 28, 20

Re: [Tutor] Variables and Functions

2007-11-28 Thread Devon MacIntyre
Hi, I have two functions, 'new_sudoku' and 'play_game'. In new_sudoku, I have a pre-determined puzzle (I wasn't able to get a randomly generated puzzle working), as a matrix in the variable 'puzzle'. I imported the 'copy' module and made a deep-copy of 'puzzle' to make 'new_puzzle', which randomly

Re: [Tutor] Variables and Functions

2007-11-28 Thread Alan Gauld
"Devon MacIntyre" <[EMAIL PROTECTED]> wrote > Just wondering, how would I get a variable out of one function and > into > another? return the value from one function and pass it as an argument to the other. Example: def oneFunction() x = [1,2,3] return x def another(aValue): pr

Re: [Tutor] Variables and Functions

2007-11-28 Thread Kent Johnson
Devon MacIntyre wrote: > Hi, > Just wondering, how would I get a variable out of one function and into > another? I don't understand your description of your situation, maybe you could show a little code as a simple example? The usual way to get a variable out of a function is to return a valu

Re: [Tutor] Variables and Functions

2007-11-28 Thread Tiger12506
Sounds like an excuse for a global (aggh!) variable. Or more properly, wrap all of the relevant functions in a class and use a class variable for your puzzle - Original Message - From: "Devon MacIntyre" <[EMAIL PROTECTED]> To: Sent: Wednesday, November 28, 2007 4:00 PM Subject: [Tutor]

Re: [Tutor] Variables in workspace

2007-10-15 Thread Alan Gauld
"Eli Brosh" <[EMAIL PROTECTED]> wrote > The dir() and del work really well ! I meant to add that if you look at the names a lot then you migt prefer PyCrust asa shell rather than IDLE. PyCrust has a small namespace window on permanent display wich shows all of the names dynamically in an ex

Re: [Tutor] Variables in workspace

2007-10-14 Thread Eli Brosh
Many thanks to Bob and Kent and all the good people in the tutor forum. The dir() and del work really well ! Eli מאת: bob gailer [mailto:[EMAIL PROTECTED] נשלח: ש 10/13/2007 17:35 אל: Kent Johnson עותק לידיעה: Eli Brosh; tutor@python.org נושא: Re: [Tutor

Re: [Tutor] Variables in workspace

2007-10-13 Thread Dave Kuhlman
On Sat, Oct 13, 2007 at 11:04:05AM +0200, Eli Brosh wrote: > > Hello > I am working with python interactively using IDLE. > > Since starting, I defined some variables: > s='string' > a=1 > b=[1,2] > c=1.02 > > and so on. > > Now, I want to know which variables are in my workspace. > That is, is

Re: [Tutor] Variables in workspace

2007-10-13 Thread Alan Gauld
"Eli Brosh" <[EMAIL PROTECTED]> wrote > Now, I want to know which variables are in my workspace. Try dir() That should give you the names in the current namespace. You will see some names you didn't define too. dir()is a really helpful command when you want to see whats possible. >>> dir('')

Re: [Tutor] Variables in workspace

2007-10-13 Thread bob gailer
Kent Johnson wrote: > bob gailer wrote: >> The del statement is the way to delete variables. Since dir() gives >> you their names one needs use eval. >> >> for varName in dir(): >> eval 'del ' + varName > > I think del globals()[varName] would work. Yep. That was nagging a corner of my brain,

Re: [Tutor] Variables in workspace

2007-10-13 Thread Kent Johnson
bob gailer wrote: > The del statement is the way to delete variables. Since dir() gives you > their names one needs use eval. > > for varName in dir(): > eval 'del ' + varName I think del globals()[varName] would work. Kent ___ Tutor maillist -

Re: [Tutor] Variables in workspace

2007-10-13 Thread bob gailer
Eli Brosh wrote: > > Hello > I am working with python interactively using IDLE. > > Since starting, I defined some variables: > s='string' > a=1 > b=[1,2] > c=1.02 > > and so on. > > Now, I want to know which variables are in my workspace. > That is, is there a command similar to "who" in MATLAB ?

Re: [Tutor] Variables in workspace

2007-10-13 Thread Kent Johnson
Eli Brosh wrote: > I am working with python interactively using IDLE. > > Since starting, I defined some variables: > > Now, I want to know which variables are in my workspace. RESTART >>> dir() ['__builtins__', '__doc__', '__name__'] >>> s='string' >>> a

Re: [Tutor] Variables of Variables

2007-01-23 Thread Tino Dai
*** Stuff deleted Wanted to give you an update. It is working now. Thank you ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Variables of Variables

2007-01-22 Thread Danny Yoo
> Actually, I started off with a dictionary with a bunch of parameters. To > give you some background, I writing my > first GUI, and using the parameters in a dictionary to control what box the > GUI displays next. So, it looks > something that looks like this: > > data={'position':'middle', >

Re: [Tutor] Variables of Variables

2007-01-22 Thread Tino Dai
On 1/18/07, Danny Yoo <[EMAIL PROTECTED]> wrote: > Rather than storing your data as variables, you could store it in a > dictionary. Then you can dynamically access data however you like.. Suggesting a dictionary here is right. ** Stuff deleted about why using variables of variables is bad **

Re: [Tutor] Variables of Variables

2007-01-18 Thread Danny Yoo
> Rather than storing your data as variables, you could store it in a > dictionary. Then you can dynamically access data however you like.. Suggesting a dictionary here is right. The technique in the original poster's question is deprecated and widely known to be a Bad Idea in Perl. See Mark

Re: [Tutor] Variables of Variables

2007-01-18 Thread John Fouhy
On 19/01/07, Tino Dai <[EMAIL PROTECTED]> wrote: > Hi Everybody, > > Is there a way to do variables of variables in python. For example in > perl: > > $foo = 'bar' > $$foo = '5' > > and $bar will have a value of 5. I have been search high and low for a > simple way to do this in python? In th

Re: [Tutor] Variables don't change when altered within a loop?

2006-06-30 Thread Alan Gauld
 > Hi, I just started picking up python yesterday, and have already come> across something that has me stumped.  I want some code that does> this:> > a = foo(a)> b = foo(b)> c = foo(c)> > So I try to do this with a for loop, like so:> > for i in [a, b, c]:>   i = foo(i)>   print i # ma

Re: [Tutor] Variables don't change when altered within a loop?

2006-06-29 Thread Bob Gailer
Evan Klitzke wrote: > Hi, I just started picking up python yesterday, and have already come > across something that has me stumped. I want some code that does > this: > > a = foo(a) > b = foo(b) > c = foo(c) > > So I try to do this with a for loop, like so: > > for i in [a, b, c]: >i = foo(i)

Re: [Tutor] Variables don't change when altered within a loop?

2006-06-29 Thread Bob Gailer
Evan Klitzke wrote: > Hi, I just started picking up python yesterday, and have already come > across something that has me stumped. I want some code that does > this: > > a = foo(a) > b = foo(b) > c = foo(c) > > So I try to do this with a for loop, like so: > > for i in [a, b, c]: >i = foo(i)

Re: [Tutor] Variables

2005-02-15 Thread Alan Gauld
Ahem, we heard you the first time! :-) Alan G. - Original Message - From: "l4 l'l1" <[EMAIL PROTECTED]> To: Sent: Tuesday, February 15, 2005 10:47 AM Subject: [Tutor] Variables > How can I do it with several variables? > > > I = "John" > print "%s used to love pizza" % I > > About

RE: [Tutor] Variables

2005-02-15 Thread Vishnu
I am forwarding this mail, since tutor@python.org is not added by Matt Hauser. Thank you, Vishnu. -Original Message- From: Matt Hauser [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 15, 2005 7:28 PM To: Vishnu Subject: Re: [Tutor] Variables #Create a list of people whoLovesPizza

RE: [Tutor] Variables

2005-02-15 Thread Vishnu
Hi, Method-I: = I1 = "John1" I2 = "John2" I3 = "John3" print "%s, %s and %s used to love pizza" % (I1,I2,I3) Method-II: = use dictionaries, name["I1"] = "John1" name["I2"] = "John2" name["I3"] = "John3" print "%{I1}s, %{I2}s and %{I3}s used to love pizza" % name HTH, Vish