Hello,
From my previous post on create dictionary from csv, i have broken the
problem further and wanted the lists feedback if it could be done better:
>>> s = 'Association of British Travel Agents (ABTA) No. 56542\nAir
Travel Organisation Licence (ATOL)\nAppointed Agents of IATA
(IATA)\nInce
I wasn't sure if that was needed, so I took it out, sorry about that. I put
ScriptAlias /cgi-bin/ "/var/www/samuelhuckins.com/cgi-bin/"
in place, reloaded, and it works! I think the problem throughout was that I was
mixing up what was necessary between CGI and mod_python.
If you'd like a ran
Le Tue, 24 Feb 2009 12:48:51 +0100,
Norman Khine s'exprima ainsi:
> Hello,
> From my previous post on create dictionary from csv, i have broken the
> problem further and wanted the lists feedback if it could be done better:
>
> >>> s = 'Association of British Travel Agents (ABTA) No. 56542\nA
On Tue, Feb 24, 2009 at 6:48 AM, Norman Khine wrote:
> Hello,
> From my previous post on create dictionary from csv, i have broken the
> problem further and wanted the lists feedback if it could be done better:
>
s = 'Association of British Travel Agents (ABTA) No. 56542\nAir Travel
Orga
Thank you all, this is great.
Kent Johnson wrote:
On Tue, Feb 24, 2009 at 6:48 AM, Norman Khine wrote:
Hello,
From my previous post on create dictionary from csv, i have broken the
problem further and wanted the lists feedback if it could be done better:
s = 'Association of British Travel Ag
Hello,
I am a beginner. And I am trying to get a user input converted to a list.
print 'Enter your first name :'
firstname = raw_input()
So if the user input is
firstname = 'foo'--->should become>
firstlist['f','o','o']
thanks in advance
___
On Tue, Feb 24, 2009 at 10:16 AM, Taylan Karaman wrote:
> Hello,
>
> I am a beginner. And I am trying to get a user input converted to a list.
>
> print 'Enter your first name :'
> firstname = raw_input()
>
> So if the user input is
>
> firstname = 'foo'--->should become>
> fir
On Tue, Feb 24, 2009 at 10:16 AM, Taylan Karaman
wrote:
> Hello,
>
> I am a beginner. And I am trying to get a user input converted to a list.
>
> print 'Enter your first name :'
> firstname = raw_input()
>
> So if the user input is
>
> firstname = 'foo' --->should become>
> fir
wormwood_3 wrote:
> I wasn't sure if that was needed, so I took it out, sorry about that. I put
>
> ScriptAlias /cgi-bin/ "/var/www/samuelhuckins.com/cgi-bin/"
>
> in place, reloaded, and it works! I think the problem throughout was
> that I was mixing up what was necessary between CGI and mod_p
Or, you could do:
In [1]: print list(raw_input('name please...'))
name please...John
['J', 'o', 'h', 'n']
Robert Berman
Kent Johnson wrote:
On Tue, Feb 24, 2009 at 10:16 AM, Taylan Karaman
wrote:
Hello,
I am a beginner. And I am trying to get a user input converted to a lis
when i call a method foo from another method func. can i access func context
variables or locals() from foo
so
def func():
i=10
foo()
in foo, can i access func's local variables on in this case i
Thanks a lot
--
Bidegg worlds best auction site
http://bidegg.com
___
I'm experimenting with OOP using the Critter Caretaker script from Python
Programming for the Absolute Beginner as my basis. I've noticed that a
dictionary/function combo is a great way to handle menus, and so I've
adapted the menu to read as:
selection = raw_input("Choice: ")
choices = {"0":quit
Le Tue, 24 Feb 2009 10:53:29 -0800,
mobiledream...@gmail.com s'exprima ainsi:
> when i call a method foo from another method func. can i access func context
> variables or locals() from foo
> so
> def func():
> i=10
> foo()
>
> in foo, can i access func's local variables on in this case i
> T
From: nathan virgil
> selection = raw_input("Choice: ")
> choices = {"0":quit, "1":crit.talk, "2":crit.eat, "3":crit.play}
> choice = choices[selection]
> choice()
>
> ...so that I can call methods from a dictionary
> the problem I'm running into with this is that
> I can't pass any perimeters thr
On Tue, Feb 24, 2009 at 10:53 AM, wrote:
> when i call a method foo from another method func. can i access func context
> variables or locals() from foo
> so
> def func():
> i=10
> foo()
>
> in foo, can i access func's local variables on in this case i
You can, but it's an evil hack that I w
Le Tue, 24 Feb 2009 14:03:09 -0500,
nathan virgil s'exprima ainsi:
> I'm experimenting with OOP using the Critter Caretaker script from Python
> Programming for the Absolute Beginner as my basis. I've noticed that a
> dictionary/function combo is a great way to handle menus, and so I've
> adapted
On Tue, Feb 24, 2009 at 2:03 PM, nathan virgil wrote:
> I'm experimenting with OOP using the Critter Caretaker script from Python
> Programming for the Absolute Beginner as my basis. I've noticed that a
> dictionary/function combo is a great way to handle menus, and so I've
> adapted the menu to r
On Tue, Feb 24, 2009 at 2:35 PM, spir wrote:
> Le Tue, 24 Feb 2009 14:03:09 -0500,
> nathan virgil s'exprima ainsi:
>> so that I can call methods from a dictionary, instead of having an
>> excruciatingly long if structure. Unfortunately, the problem I'm running
>> into with this is that I can't
> when i call a method foo from another method func. can i access func context
> variables or locals() from foo
> so
> def func():
> i=10
> foo()
>
> in foo, can i access func's local variables
A. python has statically-nested scoping, so you can do it as long as you:
1. define foo() as an in
I'm not familiar with lambdas yet, and I don't think this book will
introduce me to them; they aren't listed in the index, anyway.
Adding a bunch of single-line functions would work, but I'm not sure how
much better that is then the if structure. I think it's what I'm going to go
with, anyway. At
On Tue, Feb 24, 2009 at 5:13 PM, nathan virgil wrote:
> I'm not familiar with lambdas yet, and I don't think this book will
> introduce me to them; they aren't listed in the index, anyway.
Here are two brief introductions:
http://docs.python.org/tutorial/controlflow.html#lambda-forms
http://www.i
wrote
when i call a method foo from another method func. can i access func
context
variables or locals() from foo
Yes and there are several ways to do it, but nearly always this is a
bad idea. It will make foo almost totally unusable in any other
context since it will rely on the calling fu
On Tue, Feb 24, 2009 at 8:03 PM, nathan virgil wrote:
> I'm experimenting with OOP using the Critter Caretaker script from Python
> Programming for the Absolute Beginner as my basis. I've noticed that a
> dictionary/function combo is a great way to handle menus, and so I've
> adapted the menu to r
On Wed, Feb 25, 2009 at 12:47 AM, Andre Engels wrote:
> - Show quoted text -
> On Tue, Feb 24, 2009 at 8:03 PM, nathan virgil wrote:
>> I'm experimenting with OOP using the Critter Caretaker script from Python
>> Programming for the Absolute Beginner as my basis. I've noticed that a
>> dictionary
"nathan virgil" wrote in
selection = raw_input("Choice: ")
choices = {"0":quit, "1":crit.talk, "2":crit.eat, "3":crit.play}
choice = choices[selection]
choice()
so that I can call methods from a dictionary, instead of having an
excruciatingly long if structure. Unfortunately, the problem I'm
"nathan virgil" wrote
I'm not familiar with lambdas yet, and I don't think this book will
introduce me to them; they aren't listed in the index, anyway.
lambda is just a fancy mathematical name for a simple
concept - its a block of code, like the body of a function.
In Python its even simp
On Tue, Feb 24, 2009 at 6:50 PM, Alan Gauld wrote:
>
>
> Or you can build the param value into the dictionary:
>
> selection = raw_input("Choice: ")
> choices = {
> "0":(quit, None),
> "1":(crit.talk, "Hi there"),
> "2":(crit.eat, "Nuts"),
> "3": (crit.play, "Soccer")
> "4": (crit.play, "Baseball"
Erm, it's still not working...
Whenever I try to use the talk method (which reports the mood, and doesn't
take parameters), it says I gave it too many parameters. Maybe it might help
if I posted the code in it's entirety
# Critter Caretaker
# A virtual pet to care for
class Critter(object):
nathan virgil wrote:
Erm, it's still not working...
if selection in choices:
choice = choices[selection]
choice[0](choice[1])
s/bchoice[0]()
main()
("\n\nPress the enter key to exit.")
hth,
Emile
On Sun, 22 Feb 2009 22:21:22 +0100, roberto wrote:
> hello
> i have a question which i didn't solved yet: i can define a function
> using the text editor provided by IDLE 3.0; then i'd like to call this
> function from the python prompt
>
> but when i try to do it, python warns me that function d
On Tue, 24 Feb 2009 18:26:29 -0500, Kent Johnson wrote:
> On Tue, Feb 24, 2009 at 5:13 PM, nathan virgil
> wrote:
>> I'm not familiar with lambdas yet, and I don't think this book will
>> introduce me to them; they aren't listed in the index, anyway.
Nobody remembers partial?
from functools imp
> name like "foo" to be changed
Nitpick: "foo" is a string, not a name...
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
hi.
s = 'Association of British Travel Agents (ABTA) No.56542\nAir Travel
Organisation Licence (ATOL)\nAppointed Agents ofIATA (IATA)\nIncentive
Travel & Meet. Association (ITMA)'
licenses = re.split("\n+", s)
licenseRe = re.compile(r'\(([A-Z]+)\)( No. (\d+))?')
>>> for license in licenses:
On Wed, Feb 25, 2009 at 10:37 AM, prasad rao wrote:
>
> licenseRe = re.compile(r'\(([A-Z]+)\)( No. (\d+))?')
Change that to:
licenseRe = re.compile(r'\(([A-Z]+)\)\s*(No.\d+)?')
It now works.
Thanks,
Senthil
___
Tutor maillist - Tutor@python.org
ht
mobiledream...@gmail.com wrote:
when i call a method foo from another method func. can i access func context
variables or locals() from foo
so
def func():
i=10
foo()
in foo, can i access func's local variables on in this case i
As others have already pointed out, this is a really bad idea.
35 matches
Mail list logo