Re: beginner question-very basic

2019-08-11 Thread Wildman via Python-list
On Sun, 11 Aug 2019 12:50:29 -0400, slefkowitz wrote: > Just getting started with Python. > > Downloaded 3.7.4 rom python.org > > I wrote program in Notepad, saved it with a ".py" extension. > > What do I do next? How do I execute a program? I am assuming you are using Windows since you poste

beginner question-very basic

2019-08-11 Thread slefkowitz
Just getting started with Python. Downloaded 3.7.4 rom python.org I wrote program in Notepad, saved it with a ".py" extension. What do I do next? How do I execute a program? -- https://mail.python.org/mailman/listinfo/python-list

Re: Beginner Question

2016-06-02 Thread sohcahtoa82
at 9:42 PM, boB Stepp wrote: > >>> On Wed, Jun 1, 2016 at 7:55 PM, Marcin Rak > >>> wrote: > >>>> Hi to all > >>>> > >>>> I have a beginner question to which I have not found an answer I was able > >>>&g

Re: Beginner Question

2016-06-02 Thread Igor Korot
Steven, On Thu, Jun 2, 2016 at 1:20 AM, Steven D'Aprano wrote: > On Thursday 02 June 2016 14:21, Igor Korot wrote: > >> Hi, guys, >> >> On Wed, Jun 1, 2016 at 9:42 PM, boB Stepp wrote: >>> On Wed, Jun 1, 2016 at 7:55 PM, Marcin Rak >>> wrote: >

Re: Beginner Question

2016-06-02 Thread Marcin Rak
That linked help clear up my confusion...yes you really have to know how things work internally to understand why things happen the way they happen. Thanks again to all -- https://mail.python.org/mailman/listinfo/python-list

Re: Beginner Question

2016-06-01 Thread Steven D'Aprano
On Thursday 02 June 2016 14:21, Igor Korot wrote: > Hi, guys, > > On Wed, Jun 1, 2016 at 9:42 PM, boB Stepp wrote: >> On Wed, Jun 1, 2016 at 7:55 PM, Marcin Rak >> wrote: >>> Hi to all >>> >>> I have a beginner question to which I have not foun

Re: Beginner Question

2016-06-01 Thread Igor Korot
Hi, guys, On Wed, Jun 1, 2016 at 9:42 PM, boB Stepp wrote: > On Wed, Jun 1, 2016 at 7:55 PM, Marcin Rak > wrote: >> Hi to all >> >> I have a beginner question to which I have not found an answer I was able to >> understand. Could someone explain why the follo

Re: Beginner Question

2016-06-01 Thread Steven D'Aprano
On Thursday 02 June 2016 10:55, Marcin Rak wrote: > Hi to all > > I have a beginner question to which I have not found an answer I was able to > understand. Could someone explain why the following program: > > def f(a, L=[]): > L.append(a) > return L The d

Re: Beginner Question

2016-06-01 Thread boB Stepp
On Wed, Jun 1, 2016 at 7:55 PM, Marcin Rak wrote: > Hi to all > > I have a beginner question to which I have not found an answer I was able to > understand. Could someone explain why the following program: > > def f(a, L=[]): > L.append(a) > return L >

Beginner Question

2016-06-01 Thread Marcin Rak
Hi to all I have a beginner question to which I have not found an answer I was able to understand. Could someone explain why the following program: def f(a, L=[]): L.append(a) return L print(f(1)) print(f(2)) print(f(3)) gives us the following result: [1] [1,2] [1,2,3] How can this

Re: Beginner question - class definition error

2015-01-28 Thread Cousin Stanley
> from kivy.app import App > from kivy.uix.label import Label > > class MyApp(App): > def build(self): > return Label(text='Hello World') > > if __name__ == '__main__': > MyApp().run() > > > > I get this error when I run it: > > > Traceback (most recent call last): > File

RE: Beginner question - class definition error

2015-01-28 Thread David Aldrich
> Unindent the 'if' statement. Currently, it's indented inside the class > definition, so MyApp isn't defined yet. Thanks very much. That fixed it. Best regards David -- https://mail.python.org/mailman/listinfo/python-list

Re: Beginner question - class definition error

2015-01-28 Thread MRAB
On 2015-01-28 11:10, David Aldrich wrote: Hi I am just getting started with Python 3.3.3 and Kivy 1.8. I am using the Kivy development environment on Windows (open a command prompt and call kivy.bat). With this minimal code: import kivy kivy.require('1.8.0') from kivy.app import App from k

Beginner question - class definition error

2015-01-28 Thread David Aldrich
Hi I am just getting started with Python 3.3.3 and Kivy 1.8. I am using the Kivy development environment on Windows (open a command prompt and call kivy.bat). With this minimal code: import kivy kivy.require('1.8.0') from kivy.app import App from kivy.uix.label import Label class MyApp(App)

Re: beginner question (True False help)

2013-08-09 Thread Steven D'Aprano
On Fri, 09 Aug 2013 16:34:48 -0700, eschneider92 wrote: > What does global mean? Hi eschneider92, A few bits of advice: - You may like to actually sign your emails with a real name, or at least an alias that you want to be called, otherwise we'll just call you by your email address, and apar

Re: beginner question (True False help)

2013-08-09 Thread Joshua Landau
On 10 August 2013 00:34, wrote: > What does global mean? Python has "scopes" for its variables. Most programming languages do. A "scope" is a restriction on where variables exist -- they exist only within the scope. This can be seen in this example: def function(): # A new "scope"

Re: beginner question (True False help)

2013-08-09 Thread eschneider92
I'm sorry, but I still don't understand how it applies to my problem. Thanks for everyone's patience. -- http://mail.python.org/mailman/listinfo/python-list

Re: beginner question (True False help)

2013-08-09 Thread MRAB
On 10/08/2013 00:40, eschneide...@comcast.net wrote: (I forgot to post this with my last post.) Also, I don't understand any part of the following example, so there's no specific line that's confusing me. Thanks for the help btw. You don't understand _any_ of it? > var = 42 Here you're assi

Re: beginner question (True False help)

2013-08-09 Thread eschneider92
(I forgot to post this with my last post.) Also, I don't understand any part of the following example, so there's no specific line that's confusing me. Thanks for the help btw. var = 42 def myfunc(): var = 90 print "before:", var myfunc() print "after:", var def myfunc(): globa

Re: beginner question (True False help)

2013-08-09 Thread eschneider92
(I forgot to post this with my last post.) Also, I don't understand any part of the following example, so there's no specific line that's confusing me. Thanks for the help btw. var = 42 def myfunc(): var = 90 print "before:", var myfunc() print "after:", var def myfunc(): glo

Re: beginner question (True False help)

2013-08-09 Thread eschneider92
What does global mean? -- http://mail.python.org/mailman/listinfo/python-list

Re: beginner question (True False help)

2013-08-09 Thread Joshua Landau
On 10 August 2013 00:14, wrote: > I don't understand any of the advice any of you have given. What about it don't you understand? Pick a sentence you don't understand and throw it back at us. If you understand all the sentences but not how they come together, say so. If there's a leap that you d

Re: beginner question (True False help)

2013-08-09 Thread eschneider92
Thanks, though me not utilizing any of the other advice wasn't from lack of trying; I couldn't understand any of it. I get it now that I have a corrrect example code in front of me. -- http://mail.python.org/mailman/listinfo/python-list

Re: beginner question (True False help)

2013-08-09 Thread eschneider92
I don't understand any of the advice any of you have given. -- http://mail.python.org/mailman/listinfo/python-list

Re: beginner question (True False help)

2013-08-09 Thread Joshua Landau
On 9 August 2013 23:27, wrote: > This is what I ended up with btw. Does this insult anyone's more well attuned > Python sensibilities? ... Yes. You didn't listen to any of the advice we've been giving you. You've had *much* better answers given than this. Start from the top. We need letter

Re: beginner question (True False help)

2013-08-09 Thread eschneider92
This is what I ended up with btw. Does this insult anyone's more well attuned Python sensibilities? letters='abcdefghijkl' def repeat(): print('wanna go again?') batman=input() if batman in ('y','yes'): main() else: return def main(): print('guess a letter')

Re: beginner question (True False help)

2013-08-09 Thread eschneider92
This is what I ended up with btw. Does this insult anyone's more well-attuned Pythonic sensibilities? letters='abcdefghijkl' def repeat(): print('wanna go again?') batman=input() if batman in ('y','yes'): main() else: return def main(): print('guess a

Re: beginner question (True False help)

2013-08-09 Thread wxjmfauth
Le jeudi 8 août 2013 22:29:00 UTC+2, Terry Reedy a écrit : > On 8/8/2013 7:41 AM, Chris Angelico wrote: > > > On Thu, Aug 8, 2013 at 7:20 AM, wrote: > > > def z2(): > > >> ... letters = 'abc' > > >> ... while True: > > >> ... c = input('letter: ') > > >> ... if c

Re: beginner question (True False help)

2013-08-08 Thread Terry Reedy
On 8/8/2013 7:41 AM, Chris Angelico wrote: On Thu, Aug 8, 2013 at 7:20 AM, wrote: def z2(): ... letters = 'abc' ... while True: ... c = input('letter: ') ... if c not in letters: ... print('end, fin, Schluss') ... break ... else: ...

Re: beginner question (True False help)

2013-08-08 Thread Chris Angelico
On Thu, Aug 8, 2013 at 7:20 AM, wrote: def z2(): > ... letters = 'abc' > ... while True: > ... c = input('letter: ') > ... if c not in letters: > ... print('end, fin, Schluss') > ... break > ... else: > ... print('do stuff')

Re: beginner question (True False help)

2013-08-07 Thread wxjmfauth
Le mercredi 7 août 2013 10:17:21 UTC+2, eschne...@comcast.net a écrit : > I'm trying to create an option for the program to repeat if the user types > 'y' or 'yes', using true and false values, or otherwise end the program. If > anyone could explain to me how to get this code working, I'd appreci

Re: beginner question (True False help)

2013-08-07 Thread Larry Hudson
On 08/07/2013 01:17 AM, eschneide...@comcast.net wrote: I'm trying to create an option for the program to repeat if the user types 'y' or 'yes', using true and false values, or otherwise end the program. If anyone could explain to me how to get this code working, I'd appreciate it. letters='ab

Re: beginner question (True False help)

2013-08-07 Thread Dave Angel
eschneide...@comcast.net wrote: > What I wanted to happen is when the user typed something other than 'y' or > 'yes' after being asked 'go again?', the batman==False line would cause the > program to stop asking anything and say 'this is the end'. Instead, what is > happening is that the progra

Re: beginner question (True False help)

2013-08-07 Thread eschneider92
What I wanted to happen is when the user typed something other than 'y' or 'yes' after being asked 'go again?', the batman==False line would cause the program to stop asking anything and say 'this is the end'. Instead, what is happening is that the program just keeps going. I figured that after

Re: beginner question (True False help)

2013-08-07 Thread Joshua Landau
On 7 August 2013 09:17, wrote: > I'm trying to create an option for the program to repeat if the user types > 'y' or 'yes', using true and false values, or otherwise end the program. If > anyone could explain to me how to get this code working, I'd appreciate it. Always tell people what in par

beginner question (True False help)

2013-08-07 Thread eschneider92
I'm trying to create an option for the program to repeat if the user types 'y' or 'yes', using true and false values, or otherwise end the program. If anyone could explain to me how to get this code working, I'd appreciate it. letters='abcdefghijklmn' batman=True def thingy(): print('type le

Re: Beginner question

2013-08-06 Thread eschneider92
Thanks that helped a lot! -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner question

2013-08-06 Thread Chris Down
On 2013-08-06 14:35, eschneide...@comcast.net wrote: > Why won't the 'goodbye' part of this code work right? it prints 'ok' no > matter what is typed. Much thanks. "if" statements do not fall through, because the first statement was matched, no other ones in the same chain will be evaluted. "elif

Re: Beginner question

2013-08-06 Thread Rhodri James
On Tue, 06 Aug 2013 22:35:44 +0100, wrote: Why won't the 'goodbye' part of this code work right? it prints 'ok' no matter what is typed. Much thanks. def thing(): print('go again?') goagain=input() if goagain=='y' or 'yes': This line doesn't do what you think it does :-) Typin

Re: Beginner question

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 10:35 PM, wrote: > Why won't the 'goodbye' part of this code work right? it prints 'ok' no > matter what is typed. Much thanks. > > def thing(): > print('go again?') > goagain=input() > if goagain=='y' or 'yes': > print('ok') > elif goagain!='y' or

Re: Beginner question

2013-08-06 Thread Dave Angel
eschneide...@comcast.net wrote: > Why won't the 'goodbye' part of this code work right? it prints 'ok' no > matter what is typed. Much thanks. > > def thing(): > print('go again?') > goagain=input() > if goagain=='y' or 'yes': This expression doesn't do what you think. The compariso

Beginner question

2013-08-06 Thread eschneider92
Why won't the 'goodbye' part of this code work right? it prints 'ok' no matter what is typed. Much thanks. def thing(): print('go again?') goagain=input() if goagain=='y' or 'yes': print('ok') elif goagain!='y' or 'yes': print('goodbye') sys.exit() thing()

Re: Beginner Question: 3D Models

2013-06-19 Thread andrewblundon
On Wednesday, June 19, 2013 11:47:36 AM UTC-2:30, Rick Johnson wrote: > On Tuesday, June 18, 2013 9:47:34 PM UTC-5, andrew...@gmail.com wrote: > > > > > I'm looking at developing a program for work that can be > > > distributed to others (i.e. and exe file). The > > > application would open v

Re: Beginner Question: 3D Models

2013-06-19 Thread Rick Johnson
On Tuesday, June 18, 2013 9:47:34 PM UTC-5, andrew...@gmail.com wrote: > I'm looking at developing a program for work that can be > distributed to others (i.e. and exe file). The > application would open various dialogue boxes and ask the > user for input and eventually perform mathematical > cal

Re: Beginner Question: 3D Models

2013-06-19 Thread Fábio Santos
On Wed, Jun 19, 2013 at 2:57 PM, Oscar Benjamin wrote: > On 19 June 2013 14:14, wrote: >> This sounds similar to what I might want. So you know of any online >> tutorials for this? > > It's hard to tell what you're referring to since you haven't included > any quoted context in your message (li

Re: Beginner Question: 3D Models

2013-06-19 Thread Oscar Benjamin
On 19 June 2013 14:14, wrote: > This sounds similar to what I might want. So you know of any online tutorials > for this? It's hard to tell what you're referring to since you haven't included any quoted context in your message (like I have above). I'll assume you're referring to what Fábio said

Re: Beginner Question: 3D Models

2013-06-19 Thread andrewblundon
This sounds similar to what I might want. So you know of any online tutorials for this? -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner Question: 3D Models

2013-06-19 Thread andrewblundon
As I've said, I'm a fairly novice. I've compiled simple VB programs previously into exe files for use but nothing with pyton and nothing of this complexity. This application could potentially be distributed to hundreds of people throughout the world as our company is worldwide. Asking these peop

Re: Beginner Question: 3D Models

2013-06-19 Thread Fábio Santos
On 19 Jun 2013 12:56, "Oscar Benjamin" wrote: > > On 19 June 2013 12:13, wrote: > > > > I've seen some information on Blender. Is it possible to have the entire program contained within a single exe (or exe and some other files) so that it can be passed around and used by others without having

Re: Beginner Question: 3D Models

2013-06-19 Thread Oscar Benjamin
On 19 June 2013 12:13, wrote: > > I've seen some information on Blender. Is it possible to have the entire > program contained within a single exe (or exe and some other files) so that > it can be passed around and used by others without having to install blender? I don't know if Blender woul

Re: Beginner Question: 3D Models

2013-06-19 Thread andrewblundon
On Wednesday, June 19, 2013 3:30:41 AM UTC-2:30, Christian Gollwitzer wrote: > Am 19.06.13 04:47, schrieb andrewblun...@gmail.com: > > > However, for one part of the program I'd like to be able to create a > > > 3D model based on the user input. The model would be very basic > > > consisting of

Re: Beginner Question: 3D Models

2013-06-19 Thread andrewblundon
On Wednesday, June 19, 2013 12:50:52 AM UTC-2:30, Steven D'Aprano wrote: > On Tue, 18 Jun 2013 19:47:34 -0700, andrewblundon wrote: > > > > > However, for one part of the program I'd like to be able to create a 3D > > > model based on the user input. The model would be very basic consisting >

Re: Beginner Question: 3D Models

2013-06-18 Thread Christian Gollwitzer
Am 19.06.13 04:47, schrieb andrewblun...@gmail.com: However, for one part of the program I'd like to be able to create a 3D model based on the user input. The model would be very basic consisting of a number of lines and objects. We have 3D models of each component within our CAD system so it w

Re: Beginner Question: 3D Models

2013-06-18 Thread Steven D'Aprano
On Tue, 18 Jun 2013 19:47:34 -0700, andrewblundon wrote: > However, for one part of the program I'd like to be able to create a 3D > model based on the user input. The model would be very basic consisting > of a number of lines and objects. We have 3D models of each component > within our CAD sy

Beginner Question: 3D Models

2013-06-18 Thread andrewblundon
Hi there, Sorry for the complete beginner question but I thought the readers here might be able to provide me with some guidance. I've done some programming with Visual Basic and VBA plus a little PHP, CSS and HTML. I'm looking at developing a program for work that can be dist

Re: Beginner question

2013-06-12 Thread Chris Angelico
On Tue, Jun 4, 2013 at 9:53 PM, Carlos Nepomuceno wrote: > Are there any benefits from using dict() instead of {}? Not for what you're doing, but you can use dict() with an iterable. Most of the time, use the literal. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner question

2013-06-06 Thread Steven D'Aprano
Sorry for the delay in replying. On Tue, 04 Jun 2013 15:51:38 +0300, Carlos Nepomuceno wrote: >> [1] Technically it's a type, not a function, but the difference makes >> no difference here. > Can you explain me the difference of the type and function you've just > mentioned? We were talking ab

Re: Beginner question

2013-06-05 Thread eschneider92
Thanks everyone! -- http://mail.python.org/mailman/listinfo/python-list

Re: lstrip problem - beginner question

2013-06-04 Thread Larry Hudson
On 06/04/2013 08:21 AM, mstagliamonte wrote: Hi everyone, I am a beginner in python and trying to find my way through... :) I am writing a script to get numbers from the headers of a text file. If the header is something like: h01 = ('>scaffold_1') I just use: h01.lstrip('>scaffold_') and this

Re: lstrip problem - beginner question

2013-06-04 Thread Dave Angel
On 06/04/2013 12:01 PM, Mark Lawrence wrote: On 04/06/2013 16:49, mstagliamonte wrote: [strip the double line spaced nonsense] Can you please check your email settings. It's bad enough being plagued with double line spaced mail from google, having it come from yahoo is just adding insult to in

Re: Beginner question

2013-06-04 Thread Joshua Landau
On 4 June 2013 04:39, wrote: > Is there a more efficient way of doing this? Any help is gratly appreciated. > > > import random > def partdeux(): > print('''A man lunges at you with a knife! > Do you DUCK or PARRY?''') > option1=('duck') > option2=('parry') > optionsindex=[option1

Re: Beginner question

2013-06-04 Thread Mitya Sirenef
On 06/04/2013 07:53 AM, Carlos Nepomuceno wrote: >On 4 Jun 2013 12:28, "Carlos Nepomuceno" wrote: > [...] > >> What's going on? Is there a way to make dict() to resolve the variables? > >Well yes. > >dict(**{a:0,b:1}) > >The dict() constructor makes a dictionary from keyword arguments. So y

Re: lstrip problem - beginner question

2013-06-04 Thread mstagliamonte
Thanks to everyone! I didn't expect so many replies in such a short time! Regards, Max -- http://mail.python.org/mailman/listinfo/python-list

Re: lstrip problem - beginner question

2013-06-04 Thread Mark Lawrence
On 04/06/2013 16:49, mstagliamonte wrote: [strip the double line spaced nonsense] Can you please check your email settings. It's bad enough being plagued with double line spaced mail from google, having it come from yahoo is just adding insult to injury, thanks :) -- "Steve is going for the

Re: lstrip problem - beginner question

2013-06-04 Thread John Gordon
In <1829efca-935d-4049-ba61-7138015a2...@googlegroups.com> mstagliamonte writes: > Hi everyone, > I am a beginner in python and trying to find my way through... :) > I am writing a script to get numbers from the headers of a text file. > If the header is something like: > h01 = ('>scaffold_1'

Re: lstrip problem - beginner question

2013-06-04 Thread mstagliamonte
On Tuesday, June 4, 2013 11:48:55 AM UTC-4, MRAB wrote: > On 04/06/2013 16:21, mstagliamonte wrote: > > > Hi everyone, > > > > > > I am a beginner in python and trying to find my way through... :) > > > > > > I am writing a script to get numbers from the headers of a text file. > > > > > > I

Re: lstrip problem - beginner question

2013-06-04 Thread Peter Otten
mstagliamonte wrote: > Hi everyone, > > I am a beginner in python and trying to find my way through... :) > > I am writing a script to get numbers from the headers of a text file. > > If the header is something like: > h01 = ('>scaffold_1') > I just use: > h01.lstrip('>scaffold_') > and this re

Re: lstrip problem - beginner question

2013-06-04 Thread mstagliamonte
On Tuesday, June 4, 2013 11:41:43 AM UTC-4, Fábio Santos wrote: > On 4 Jun 2013 16:34, "mstagliamonte" wrote: > > > > > > On Tuesday, June 4, 2013 11:21:53 AM UTC-4, mstagliamonte wrote: > > > > Hi everyone, > > > > > > > > > > > > > > > > I am a beginner in python and trying to find my way

Re: lstrip problem - beginner question

2013-06-04 Thread MRAB
On 04/06/2013 16:21, mstagliamonte wrote: Hi everyone, I am a beginner in python and trying to find my way through... :) I am writing a script to get numbers from the headers of a text file. If the header is something like: h01 = ('>scaffold_1') I just use: h01.lstrip('>scaffold_') and this re

Re: lstrip problem - beginner question

2013-06-04 Thread Fábio Santos
On 4 Jun 2013 16:34, "mstagliamonte" wrote: > > On Tuesday, June 4, 2013 11:21:53 AM UTC-4, mstagliamonte wrote: > > Hi everyone, > > > > > > > > I am a beginner in python and trying to find my way through... :) > > > > > > > > I am writing a script to get numbers from the headers of a text file.

Re: lstrip problem - beginner question

2013-06-04 Thread mstagliamonte
On Tuesday, June 4, 2013 11:21:53 AM UTC-4, mstagliamonte wrote: > Hi everyone, > > > > I am a beginner in python and trying to find my way through... :) > > > > I am writing a script to get numbers from the headers of a text file. > > > > If the header is something like: > > h01 = ('>sca

Re: lstrip problem - beginner question

2013-06-04 Thread mstagliamonte
On Tuesday, June 4, 2013 11:21:53 AM UTC-4, mstagliamonte wrote: > Hi everyone, > > > > I am a beginner in python and trying to find my way through... :) > > > > I am writing a script to get numbers from the headers of a text file. > > > > If the header is something like: > > h01 = ('>sca

Re: lstrip problem - beginner question

2013-06-04 Thread mstagliamonte
On Tuesday, June 4, 2013 11:21:53 AM UTC-4, mstagliamonte wrote: > Hi everyone, > > > > I am a beginner in python and trying to find my way through... :) > > > > I am writing a script to get numbers from the headers of a text file. > > > > If the header is something like: > > h01 = ('>sca

Re: lstrip problem - beginner question

2013-06-04 Thread mstagliamonte
On Tuesday, June 4, 2013 11:21:53 AM UTC-4, mstagliamonte wrote: > Hi everyone, > > > > I am a beginner in python and trying to find my way through... :) > > > > I am writing a script to get numbers from the headers of a text file. > > > > If the header is something like: > > h01 = ('>sca

lstrip problem - beginner question

2013-06-04 Thread mstagliamonte
Hi everyone, I am a beginner in python and trying to find my way through... :) I am writing a script to get numbers from the headers of a text file. If the header is something like: h01 = ('>scaffold_1') I just use: h01.lstrip('>scaffold_') and this returns me '1' But, if the header is: h02: ('

Re: Beginner question

2013-06-04 Thread Roy Smith
In article , Larry Hudson wrote: > def partdeux(): > print('A man lunges at you with a knife!') > option = input('Do you DUCK or PARRY? ').lower() > success = random.randint(0, 1) > if success: > if option == 'duck': > print('He tumbles over you') >

RE: Beginner question

2013-06-04 Thread Carlos Nepomuceno
> From: steve+comp.lang.pyt...@pearwood.info > Subject: Re: Beginner question > Date: Tue, 4 Jun 2013 12:35:59 + > To: python-list@python.org > > On Tue, 04 Jun 2013 14:23:39 +0300, Carlos Nepomuceno wrote: > > > Started answering... now I'm asking! lol >

RE: Beginner question

2013-06-04 Thread Fábio Santos
> > Awesome! Now I can do it just like that: > > >>> dict([(chr(ord('a')+x),x) for x in range(2)]) > {'a': 0, 'b': 1} > > Thanks a lot! ;) > Or dict((c, i) for (i, c) in enumerate('ab')) But at this point you could just use a dict comprehension. {c: i for i, c in enumerate('ab')} -- http://mail

Re: Beginner question

2013-06-04 Thread Steven D'Aprano
On Tue, 04 Jun 2013 14:23:39 +0300, Carlos Nepomuceno wrote: > Started answering... now I'm asking! lol > > I've tried to use dict() to create a dictionary to use like the switch > statement providing variable names instead of literals, such as: > a='A' b='B' {a:0,b:1}#here th

RE: Beginner question

2013-06-04 Thread Carlos Nepomuceno
> From: steve+comp.lang.pyt...@pearwood.info > Subject: Re: Beginner question > Date: Tue, 4 Jun 2013 12:25:27 + > To: python-list@python.org > > On Tue, 04 Jun 2013 14:53:29 +0300, Carlos Nepomuceno wrote: > > > That's exactly the same! > >&g

Re: Beginner question

2013-06-04 Thread Steven D'Aprano
On Tue, 04 Jun 2013 14:53:29 +0300, Carlos Nepomuceno wrote: > That's exactly the same! dict(**{a:0,b:1})=={a:0,b:1} > True Of course it is. Isn't that what you wanted? It's also a waste of time, because you create a dict literal using {}, then unpack it into keyword arguments, then call d

RE: Beginner question

2013-06-04 Thread Fábio Santos
On 4 Jun 2013 12:57, "Carlos Nepomuceno" wrote: > > >On 4 Jun 2013 12:28, "Carlos Nepomuceno" wrote: > [...] > > >> What's going on? Is there a way to make dict() to resolve the variables? > >Well yes. > >dict(**{a:0,b:1}) > >The dict() constructor makes a dictionary from keyword arguments. So yo

RE: Beginner question

2013-06-04 Thread Carlos Nepomuceno
>On 4 Jun 2013 12:28, "Carlos Nepomuceno" wrote: [...] >> What's going on? Is there a way to make dict() to resolve the variables? >Well yes. >dict(**{a:0,b:1}) >The dict() constructor makes a dictionary from keyword arguments. So you just >have to feed it keyword arguments using **. >And if you'

RE: Beginner question

2013-06-04 Thread Fábio Santos
On 4 Jun 2013 12:28, "Carlos Nepomuceno" wrote: > > Started answering... now I'm asking! lol > > I've tried to use dict() to create a dictionary to use like the switch statement providing variable names instead of literals, such as: > > >>> a='A' > >>> b='B' > >>> {a:0,b:1}#here the variables

RE: Beginner question

2013-06-04 Thread Carlos Nepomuceno
Started answering... now I'm asking! lol I've tried to use dict() to create a dictionary to use like the switch statement providing variable names instead of literals, such as: >>> a='A' >>> b='B' >>> {a:0,b:1}#here the variables are resolved {'A': 0, 'B': 1} That's ok! But if I use dict()

Re: Beginner question

2013-06-04 Thread Peter Otten
Chris Angelico wrote: > On Tue, Jun 4, 2013 at 5:57 PM, John Ladasky > wrote: >> On Tuesday, June 4, 2013 12:45:38 AM UTC-7, Anssi Saari wrote: >> >>> BTW, did I get the logic correctly, the end result is random? >> >> You're right! I'm guessing that's not what the OP wants? > > I'm guessing th

Re: Beginner question

2013-06-04 Thread Larry Hudson
On 06/03/2013 08:39 PM, eschneide...@comcast.net wrote: Is there a more efficient way of doing this? Any help is gratly appreciated. import random def partdeux(): print('''A man lunges at you with a knife! Do you DUCK or PARRY?''') option1=('duck') option2=('parry') optionsi

Re: Beginner question

2013-06-04 Thread Chris Angelico
On Tue, Jun 4, 2013 at 5:57 PM, John Ladasky wrote: > On Tuesday, June 4, 2013 12:45:38 AM UTC-7, Anssi Saari wrote: > >> BTW, did I get the logic correctly, the end result is random? > > You're right! I'm guessing that's not what the OP wants? I'm guessing that's exactly what the OP wants. This

RE: Beginner question

2013-06-04 Thread Carlos Nepomuceno
> Date: Tue, 4 Jun 2013 00:53:04 -0700 > Subject: Re: Beginner question > From: john_lada...@sbcglobal.net > To: python-list@python.org > > On Monday, June 3, 2013 11:46:03 PM UTC-7, Carlos Nepomuceno wrote: > > That doesn't even works because input() is the same

Re: Beginner question

2013-06-04 Thread John Ladasky
On Tuesday, June 4, 2013 12:45:38 AM UTC-7, Anssi Saari wrote: > BTW, did I get the logic correctly, the end result is random? You're right! I'm guessing that's not what the OP wants? -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner question

2013-06-04 Thread John Ladasky
On Monday, June 3, 2013 11:46:03 PM UTC-7, Carlos Nepomuceno wrote: > That doesn't even works because input() is the same as eval(raw_input()). So > you'll get a NameError exception. > > I think you know that. Perhaps you mean raw_input() instead of input(). But the OP's code shows print() funct

Re: Beginner question

2013-06-04 Thread Anssi Saari
eschneide...@comcast.net writes: > Is there a more efficient way of doing this? Any help is gratly appreciated. Efficiency in a short program isn't a big thing. You have some pretty weird things in there, there's no need make single element tuples out of your strings and then putting those in a l

RE: Beginner question

2013-06-03 Thread Carlos Nepomuceno
er, default)() Note that switch is a dictionary and you can use it without creating a variable, for example: { option1: function1, option2: function2 }.get(randomizer, default)() > Date: Mon, 3 Jun 2013 20:39:28 -0700 > Subject: Beginner question > From: eschneide...@comcast.net > T

Beginner question

2013-06-03 Thread eschneider92
Is there a more efficient way of doing this? Any help is gratly appreciated. import random def partdeux(): print('''A man lunges at you with a knife! Do you DUCK or PARRY?''') option1=('duck') option2=('parry') optionsindex=[option1, option2] randomizer=random.choice(optionsin

Re: Learning new APIs/classes (beginner question)

2012-04-07 Thread Martin Jones
On Apr 7, 1:52 am, Steven D'Aprano wrote: > Sounds like this library is documented the same way most third party > libraries are: as an afterthought, by somebody who is so familiar with > the software that he cannot imagine why anyone might actually need > documentation. > > I feel your pain. >

Re: Learning new APIs/classes (beginner question)

2012-04-06 Thread Steven D'Aprano
On Fri, 06 Apr 2012 13:41:23 -0700, Martin Jones wrote: > In a nutshell: My question is: how do experienced coders learn about > external/third-party classes/APIs? Does it have a tutorial? Do it. Does it have a manual, a wiki, FAQs, or other documentation? Read them. If all else fails, what doe

Re: Learning new APIs/classes (beginner question)

2012-04-06 Thread Emile van Sebille
On 4/6/2012 1:41 PM Martin Jones said... In a nutshell: My question is: how do experienced coders learn about external/third-party classes/APIs? I'm teaching myself Python through a combination of Hetland's 'Beginning Python', various online tutorials and some past experience coding ASP/VBScript

Learning new APIs/classes (beginner question)

2012-04-06 Thread Martin Jones
In a nutshell: My question is: how do experienced coders learn about external/third-party classes/APIs? I'm teaching myself Python through a combination of Hetland's 'Beginning Python', various online tutorials and some past experience coding ASP/VBScript. To start to learn Python I've set myself

Re: redis beginner question

2011-11-16 Thread Rafael Durán Castañeda
El 16/11/11 03:22, Jabba Laci escribió: Hi, I'm reading the redis documentation and there is one thing that bothers me. For redis, you need to start a server on localhost. Is there an easy way that my Python script starts this server automatically? Before using my script, I don't want to start r

Re: redis beginner question

2011-11-16 Thread Roy Smith
In article , Jabba Laci wrote: > > Why do you want to stop redis after your program terminates?  Generally, > > you just start redis up when the system boots and leave it running. > > Hi, > > OK, so it's more like MySQL or PostgeSQL, i.e. leave the server > running in the background. That's h

  1   2   3   >