Re: [Tutor] input string to own console stdin

2017-11-15 Thread Alan Gauld via Tutor
On 15/11/17 22:16, Eddio 0141 wrote: > Hi. > I've been searching on google about inputting to own stdin and press enter > but so far i haven't found anything at all. You need to give us a bit more context. This doesn't look like standard library stuff so which package are you using? (Is that what

[Tutor] input string to own console stdin

2017-11-15 Thread Eddio 0141
Hi. I've been searching on google about inputting to own stdin and press enter but so far i haven't found anything at all. so what im trying to do is the chatterbot function i got on python doesn't seem to accept string as an input and always wants a console input and Enter (the line -> response =

Re: [Tutor] Input Files

2014-11-19 Thread Peter Otten
niyanax...@gmail.com wrote: > How do I know write the loop code for the table for both inputfiles, > Table1.txt and Table2.txt and make a third table from the elements > multiplied in table1.txt and table2.txt. I'm trying to Check the size of > the two tables to make sure they both have the same n

[Tutor] Input Files

2014-11-19 Thread niyanaxx95
How do I know write the loop code for the table for both inputfiles, Table1.txt and Table2.txt and make a third table from the elements multiplied in table1.txt and table2.txt. I'm trying to Check the size of the two tables to make sure they both have the same number of rows and columns o If the

Re: [Tutor] input python 3.3

2014-02-04 Thread Dave Angel
Ian D Wrote in message: > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > When making an amendment to a post, please reply to that post; don't start a new

Re: [Tutor] input python 3.3

2014-02-04 Thread Alan Gauld
On 04/02/14 09:01, Ian D wrote: I used to use 2.7 and the input was pretty when inputting a numeric value, it would just get cast to an int. Just to be picky it would get converted to an int not cast as an int. casting and converting are two very different things. casting means treat a bit pa

Re: [Tutor] input python 3.3

2014-02-04 Thread Peter Otten
Ian D wrote: > Hello > > I used to use 2.7 and the input was pretty when inputting a numeric value, > it would just get cast to an int. > > Seems that 3.3 I have to cast each input so : > float(num1 = input("Enter a number") You mean num1 = float(input("Enter a number")) > Is this just t

[Tutor] input syntax I just posted totally wrong

2014-02-04 Thread Ian D
num1 = float(input("enter a number ")) I meant not float(num1 = input("Enter a number")) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org

[Tutor] input python 3.3

2014-02-04 Thread Ian D
Hello I used to use 2.7 and the input was pretty when inputting a numeric value, it would just get cast to an int. Seems that 3.3 I have to cast each input so : float(num1 = input("Enter a number") Is this just they way it is now? Is there a way to get back to just typing: num1 = input("Ent

Re: [Tutor] input loop

2013-09-01 Thread Alan Gauld
On 01/09/13 22:53, Nick Wilson wrote: Enter command: print -- Code Price Quant Value -- The bit above needs to be printed once, at the start TPW 2.00 5 10.00 This bit needs to be repeated for eac

Re: [Tutor] input loop

2013-09-01 Thread Dave Angel
On 1/9/2013 17:53, Nick Wilson wrote: > Hi, Welcome. Please start over with a text message. Your html email is useless to me, and probably most people on this newsgroup.     5       10.00--Total cost:                  10.00==**(T

[Tutor] input loop

2013-09-01 Thread Nick Wilson
Hi, I am trying to create a portfolio of shares, each share is entered manually while checking it against a list of actual share codes.Its working mostly as intended at the moment, except when I print the table out at the end, I want all entered details printed as such Enter command: addEnter sh

Re: [Tutor] Input into lists?

2013-08-16 Thread leam hall
Hey Dave, you're right. I worked through this with a for loop and set the contents of a dict's key as the input. Thanks! Leam On Thu, Aug 15, 2013 at 8:28 PM, Dave Angel wrote: > leam hall wrote: > > > I'm trying to take input from a file (CSV spreadsheet) and use the first > > line inputs (h

Re: [Tutor] Input into lists?

2013-08-15 Thread Dave Angel
leam hall wrote: > I'm trying to take input from a file (CSV spreadsheet) and use the first > line inputs (header) as the names of lists. So far I'm not successful. :) > > How do I take line_list[0], the result of "line.split(',')" and use it as > the name of a list? Does that make sense? > No,

Re: [Tutor] Input into lists?

2013-08-15 Thread Alan Gauld
On 13/08/13 16:46, leam hall wrote: I'm trying to take input from a file (CSV spreadsheet) and use the first line inputs (header) as the names of lists. So far I'm not successful. :) Have you tried the csv module? Usually you use a dictionary keyed by the first line values though. But i#'m s

[Tutor] Input into lists?

2013-08-15 Thread leam hall
I'm trying to take input from a file (CSV spreadsheet) and use the first line inputs (header) as the names of lists. So far I'm not successful. :) How do I take line_list[0], the result of "line.split(',')" and use it as the name of a list? Does that make sense? Thanks! Leam -- Mind on a Mis

Re: [Tutor] Input handling?

2012-09-18 Thread Scott Yamamoto
Thanks for everything. I'll keep this in mind as I continue coding.___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Input handling?

2012-09-18 Thread eryksun
On Tue, Sep 18, 2012 at 1:23 PM, Scott Yamamoto wrote: > > 1) expect: raw_input to assign the variable to "" > 2)No output to stderr; has a loading symbol after hitting enter without input > (tried both input and raw_input) > Doesn't affect active interpreter. Only affects the screen with the run

Re: [Tutor] Input handling?

2012-09-18 Thread Scott Yamamoto
0) using mobile yahoo mail 1) expect: raw_input to assign the variable to "" 2)No output to stderr; has a loading symbol after hitting enter without input (tried both input and raw_input) Doesn't affect active interpreter. Only affects the screen with the run option. 3) def simulation():   import

Re: [Tutor] Input handling?

2012-09-18 Thread Oscar Benjamin
On Sep 18, 2012 10:02 AM, "Oscar Benjamin" wrote: > > > On Sep 18, 2012 7:14 AM, "Steven D'Aprano" wrote: > > Apologies for gmail screwing up your name. I wish I could use mutt on this machine. Oscar ___ Tutor maillist - Tutor@python.org To unsubscr

Re: [Tutor] Input handling?

2012-09-18 Thread Oscar Benjamin
On Sep 18, 2012 7:14 AM, "Steven D'Aprano" wrote: > > On Tue, Sep 18, 2012 at 12:04:22AM -0400, Dave Angel wrote: > > Somehow you managed to put your other message in its own thread, instead > > of adding to this one. > > Not all mail clients support threading, either when receiving or > sending.

Re: [Tutor] Input handling?

2012-09-17 Thread Dave Angel
On 09/18/2012 02:12 AM, Steven D'Aprano wrote: > On Tue, Sep 18, 2012 at 12:04:22AM -0400, Dave Angel wrote: >> On 09/17/2012 11:11 PM, Scott Yamamoto wrote: >>> I've been trying to find possible erros with input(such as NameError or >>> SyntaxError) to handle them with an except clause. however,

Re: [Tutor] Input handling?

2012-09-17 Thread Steven D'Aprano
On Mon, Sep 17, 2012 at 09:19:41PM -0700, Scott Yamamoto wrote: > 2.7.2 on python for ios(platform is darwin) > problem reoccured What problem? Your code works for me. Please describe: 1) what you expect to happen 2) what actually happens 3) if there is a traceback, COPY AND PASTE the ENTIRE tra

Re: [Tutor] Input handling?

2012-09-17 Thread Steven D'Aprano
On Tue, Sep 18, 2012 at 12:04:22AM -0400, Dave Angel wrote: > On 09/17/2012 11:11 PM, Scott Yamamoto wrote: > > I've been trying to find possible erros with input(such as NameError or > > SyntaxError) to handle them with an except clause. however, I've found > > that hitting enter/return while pr

Re: [Tutor] Input handling?

2012-09-17 Thread Scott Yamamoto
2.7.2 on python for ios(platform is darwin) problem reoccured Script: import random username = "" def playername(): global username Mlist = ["name1","name2","name3"] Flist = ["name4","name5", "name6"] Llist = ["Lname1","Lname2","Lname3"] username = raw_input("input your desired username:

Re: [Tutor] Input handling?

2012-09-17 Thread Dave Angel
On 09/17/2012 11:11 PM, Scott Yamamoto wrote: > I've been trying to find possible erros with input(such as NameError or > SyntaxError) to handle them with an except clause. however, I've found > that hitting enter/return while prompted without inputting creates some kind > of problem. usern

Re: [Tutor] Input handling?

2012-09-17 Thread Scott Yamamoto
Didnt show up at first. Result was an eof error (using input not raw_input) Found with interactive interpreter___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Input handling?

2012-09-17 Thread Scott Yamamoto
I've been trying to find possible erros with input(such as NameError or SyntaxError) to handle them with an except clause. however, I've found that hitting enter/return while prompted without inputting creates some kind of problem. >>>username = raw_input("Input a username: ") Input a username:

Re: [Tutor] Input

2011-10-01 Thread Ed Hughes
> 3. fake defrag revisited (R. Alan Monroe) > 4. Re: guess age programme (please help) (Alan Gauld) > > > -- > > Message: 1 > Date: Sat, 01 Oct 2011 12:36:57 +1000 > From: Steven D'Aprano > To: tutor@pyt

Re: [Tutor] Input

2011-09-30 Thread Steven D'Aprano
Cameron Macleod wrote: Hi, When you type Input("\n\nPress The Enter Key To Exit") it forces you to press the enter key to close the program. Why is it the enter key instead of e.g. the 'esc' key? Because the convention is that you use the Enter key to ENTER information. That's why it is cal

Re: [Tutor] Input

2011-09-30 Thread bodsda
To: Cc: Subject: Re: [Tutor] Input ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Input

2011-09-30 Thread Mark Lybrand
There is apparently a livewires package that may be of someuse. On Sep 30, 2011 1:25 PM, "Dave Angel" wrote: > On 09/30/2011 03:24 PM, Cameron Macleod wrote: >> Hi, >> >> When you type >> >> Input("\n\nPress The Enter Key To Exit") >> >> it forces you to press the enter key to close the program. W

Re: [Tutor] Input

2011-09-30 Thread Dave Angel
On 09/30/2011 03:24 PM, Cameron Macleod wrote: Hi, When you type Input("\n\nPress The Enter Key To Exit") it forces you to press the enter key to close the program. Why is it the enter key instead of e.g. the 'esc' key? The input() function (not the Input()) function accepts a line of text

[Tutor] Input

2011-09-30 Thread Cameron Macleod
Hi, When you type Input("\n\nPress The Enter Key To Exit") it forces you to press the enter key to close the program. Why is it the enter key instead of e.g. the 'esc' key? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription o

Re: [Tutor] input and raw input

2010-09-28 Thread John Chandler
you can use an re split... import re a=raw_input("Enter the number of your class in the school:") regex = re.compile("[ ,]") #sets the delimeters to a single space or comma m = regex.split(a) if you want to use any white space character than you can use "[\s,]" 2010/9/23 Ahmed AL-Masri > Hi,

Re: [Tutor] input and raw input

2010-09-25 Thread Peter Otten
Brian Jones wrote: > No need for the 're' module. Even in the case where both can be used > together, you can still just use string methods: > s > '12, 13 14' s.replace(',', '').split(' ') > ['12', '13', '14'] I think to replace "," with " " and then split() without explicit separator

Re: [Tutor] input and raw input

2010-09-25 Thread Evert Rol
> > any one have an idea about how we can input many number in the one time and > > change it to list. > > for example: > > > > a=input("Enter the number of your class in the school:") # the number > > can be enter as: 12,13,14 or 12 13 14 with a space in between. > > > > now how I can put th

Re: [Tutor] input and raw input

2010-09-25 Thread Brian Jones
On Sat, Sep 25, 2010 at 9:40 AM, Evert Rol wrote: > > any one have an idea about how we can input many number in the one time > and change it to list. > > for example: > > > > a=input("Enter the number of your class in the school:") # the number > can be enter as: 12,13,14 or 12 13 14 with a

Re: [Tutor] input and raw input

2010-09-25 Thread Evert Rol
> any one have an idea about how we can input many number in the one time and > change it to list. > for example: > > a=input("Enter the number of your class in the school:") # the number can > be enter as: 12,13,14 or 12 13 14 with a space in between. > > now how I can put these numbers

[Tutor] input and raw input

2010-09-25 Thread Ahmed AL-Masri
Hi, any one have an idea about how we can input many number in the one time and change it to list. for example: a=input("Enter the number of your class in the school:") # the number can be enter as: 12,13,14 or 12 13 14 with a space in between. now how I can put these numbers into list like

Re: [Tutor] input problem

2010-09-14 Thread Alan Gauld
"ANKUR AGGARWAL" wrote Suppose i am taking input or various variables like a=raw_input("...") //hello b=raw_input("")//hi but i want to run a common function when input is hello so instead of if a=="hello": fun() then again for b and then again for c then d and so

Re: [Tutor] input problem

2010-09-13 Thread James Mills
On Tue, Sep 14, 2010 at 6:45 AM, ANKUR AGGARWAL wrote: > Suppose i am taking input or various variables like > a=raw_input("...") //hello > b=raw_input("")//hi > c=raw_input("...")//hello > d=raw_input("..")//hello > but i want to run a common functi

Re: [Tutor] input problem

2010-09-13 Thread christopher . henk
ANKUR AGGARWAL wrote on 09/13/2010 04:45:41 PM: > Suppose i am taking input or various variables like > a=raw_input("...") //hello > b=raw_input("")//hi > c=raw_input("...")//hello > d=raw_input("..")//hello > but i want to run a common function when

[Tutor] input problem

2010-09-13 Thread ANKUR AGGARWAL
Suppose i am taking input or various variables like a=raw_input("...") //hello b=raw_input("")//hi c=raw_input("...")//hello d=raw_input("..")//hello but i want to run a common function when input is hello so instead of if a=="hello": fun() then aga

Re: [Tutor] input problem

2010-08-22 Thread Nick Raptis
Please try and reply to the list instead of just me. raw_input did not the trick. fruit.count is the next exercise. Oke, I deleted the initialazion and change teller into letter. Roelof Should be alright now.. Hmmm Can you paste your exact code AND the error you're getting? As I understand

Re: [Tutor] input problem

2010-08-22 Thread Nick Raptis
On 08/22/2010 09:35 PM, Roelof Wobben wrote: Hello, I made this programm : def count_letters(n,a): count = 0 for char in n: if char == a: count += 1 return count fruit="" letter="" fruit= input("Enter a sort of fruit: ") teller = input("Enter the character which

Re: [Tutor] input problem

2010-08-22 Thread Alex Hall
On 8/22/10, Roelof Wobben wrote: > > Hello, > > > > I made this programm : > > > > def count_letters(n,a): > count = 0 > for char in n: > if char == a: > count += 1 > return count > > fruit="" > letter="" > fruit= input("Enter a sort of fruit: ") > teller = input("E

Re: [Tutor] input problem

2010-08-22 Thread Nick Raptis
On 08/22/2010 09:35 PM, Roelof Wobben wrote: Hello, I made this programm : def count_letters(n,a): count = 0 for char in n: if char == a: count += 1 return count fruit="" letter="" fruit= input("Enter a sort of fruit: ") teller = input("Enter the character which

[Tutor] input problem

2010-08-22 Thread Roelof Wobben
Hello, I made this programm : def count_letters(n,a): count = 0 for char in n: if char == a: count += 1 return count fruit="" letter="" fruit= input("Enter a sort of fruit: ") teller = input("Enter the character which must be counted: ") x=count_letters (f

Re: [Tutor] Input() is not working as expected in Python 3.1

2010-02-15 Thread Yaraslau Shanhin
Thanks for try but print without () does not work at all, at least in newer version of python (3.1) Anyway source of problem is now discovered: Komodo Edit tool, in Python shell (IDLE) everything works fine. Perhaps anyone has any ideas why? On Mon, Feb 15, 2010 at 10:02 PM, Grigor Kolev wrote:

Re: [Tutor] Input() is not working as expected in Python 3.1

2010-02-15 Thread Grigor Kolev
В 10:06 -0500 на 15.02.2010 (пн), bob gailer написа: > Yaraslau Shanhin wrote: > > > Hello All, > > Hello. > > Suggestion for future questions - just include enough to identify the > problem. We don't need to know that this is from a tutorial or what the > exercise is. Also (at least I prefer

Re: [Tutor] Input() is not working as expected in Python 3.1

2010-02-15 Thread Rich Lovely
On 15 February 2010 15:15, Yaraslau Shanhin wrote: > Code: > text = str(input("Type in some text: ")) > number = int(input("How many times should it be printed? ")) > print (text * number) > Output: > Type in some text: some > How many times should it be printed? 5 > Traceback (most recent call la

Re: [Tutor] Input() is not working as expected in Python 3.1

2010-02-15 Thread Yaraslau Shanhin
Code: text = str(input("Type in some text: ")) number = int(input("How many times should it be printed? ")) print (text * number) Output: Type in some text: some How many times should it be printed? 5 Traceback (most recent call last): File "test4.py", line 2, in number = int(input("How ma

Re: [Tutor] Input() is not working as expected in Python 3.1

2010-02-15 Thread bob gailer
Yaraslau Shanhin wrote: > Hello All, Hello. Suggestion for future questions - just include enough to identify the problem. We don't need to know that this is from a tutorial or what the exercise is. Also (at least I prefer) plain text without formatting or color. Sufficient therefore is:

Re: [Tutor] Input() is not working as expected in Python 3.1

2010-02-15 Thread Dave Angel
Yaraslau Shanhin wrote: Hello All, I am working with Python tutorial in wiki and one of the exercises is as follows: Ask the user for a string, and then for a number. Print out that string, that many times. (For example, if the string is hello and the number is 3 you should print out hellohello

Re: [Tutor] Input() is not working as expected in Python 3.1

2010-02-15 Thread Wayne Werner
On Mon, Feb 15, 2010 at 8:23 AM, Yaraslau Shanhin < yaraslau.shan...@gmail.com> wrote: > Hello All, > > I am working with Python tutorial in wiki and one of the exercises is as > follows: > > Ask the user for a string, and then for a number. Print out that string, > that many times. (For example,

[Tutor] Input() is not working as expected in Python 3.1

2010-02-15 Thread Yaraslau Shanhin
Hello All, I am working with Python tutorial in wiki and one of the exercises is as follows: Ask the user for a string, and then for a number. Print out that string, that many times. (For example, if the string is hello and the number is 3 you should print out hellohellohello.) Solution for this

Re: [Tutor] Input validation

2009-09-04 Thread Rich Lovely
2009/9/3 Albert-Jan Roskam : > Hi, > > I'm wondering what is the most common method of input validation. See the > example below. > -Is the code below the most common/recognizable way something like this is > done? > -Which of the options #1 and #2 is the preferred method? Option #2 looks less >

Re: [Tutor] Input validation

2009-09-03 Thread Alan Gauld
"Albert-Jan Roskam" wrote I'm wondering what is the most common method of input validation. Any and all of the methods will work in different situations but its generally best to use duck typing and try to write code that works for any type as far as possible. Then use exceptions to catc

[Tutor] Input validation

2009-09-03 Thread Albert-Jan Roskam
Hi, I'm wondering what is the most common method of input validation. See the example below. -Is the code below the most common/recognizable way something like this is done? -Which of the options #1 and #2 is the preferred method? Option #2 looks less esoteric, but #1 seems better when you have

Re: [Tutor] input and output files from terminal

2008-04-17 Thread Alan Gauld
"Brain Stormer" <[EMAIL PROTECTED]> wrote > Thanks for the file direction method but how do I get the names of > the files > so I can use it inside my program. I'm not sure I understand. Thepoint of using redirection is that your code doesn't need to know anything about the files, it just read

Re: [Tutor] input and output files from terminal

2008-04-17 Thread Brain Stormer
Actually, Let me take that back with the raw_input comment since it is not the idle issue but I didn't want to the program to be interactive so I didn't want to wait for someone to put the information and press enter. Thanks for the file direction method but how do I get the names of the files so I

Re: [Tutor] input and output files from terminal

2008-04-14 Thread Alan Gauld
"Brain Stormer" <[EMAIL PROTECTED]> wrote >I have a python program which works fine when run using idle but I >would > like call the program from the terminal. > > python test.py -i inputfile -o outputfile Easier to use file redirection: python test.py < inputfile > outputfile The -i flag in

Re: [Tutor] input and output files from terminal

2008-04-14 Thread Brain Stormer
I used the optparse module since that is exactly what I wanted. Here is my code: import sys from optparse import OptionParser import os parser = OptionParser() parser.add_option("-i", "--input", dest="infile", help="input FILE to convert", metavar="FILE") parser.add_option("-o", "--output", dest

Re: [Tutor] input and output files from terminal

2008-04-14 Thread bhaaluu
On Mon, Apr 14, 2008 at 12:55 PM, Brain Stormer <[EMAIL PROTECTED]> wrote: > I have a python program which works fine when run using idle but I would > like call the program from the terminal. > > python test.py -i inputfile -o outputfile > > I tried with raw_input but that only works in idle. Can

Re: [Tutor] input and output files from terminal

2008-04-14 Thread linuxian iandsd
i think you need to try : cat input.txt | /usr/bin/python test.py >output.txt > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] input and output files from terminal

2008-04-14 Thread v2punkt0
look at the OptParse module, with this u can easily realize such things. http://docs.python.org/lib/module-optparse.html On Mon, Apr 14, 2008 at 12:55:07PM -0400, Brain Stormer wrote: > I have a python program which works fine when run using idle but I would > like call the program from the termi

[Tutor] input and output files from terminal

2008-04-14 Thread Brain Stormer
I have a python program which works fine when run using idle but I would like call the program from the terminal. python test.py -i inputfile -o outputfile I tried with raw_input but that only works in idle. Can this be achieved? Thanks ___ Tutor maill

Re: [Tutor] Input

2008-01-16 Thread Ricardo Aráoz
Kent Johnson wrote: > Ricardo Aráoz wrote: > >> _validChars = { >> 'X' : >> 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' >> , '9' : '1234567890' >> , '-' : '-1234567890' >> , 'A' : >> 'abcdefghijklmnopqrstuvwxyzABC

Re: [Tutor] Input

2008-01-16 Thread Alan Gauld
"Tiger12506" <[EMAIL PROTECTED]> wrote >> Of course I know and use reg. exps., the point of the function is >> not to >> validate input but to force the proper input. > > So? Are you going to try to tell me that you can force particular > input > without actually determining if its valid or not f

Re: [Tutor] Input

2008-01-16 Thread Ricardo Aráoz
Tiger12506 wrote: >> Of course I know and use reg. exps., the point of the function is not to >> validate input but to force the proper input. > > So? Are you going to try to tell me that you can force particular input > without actually determining if its valid or not first? ;-) > > Just a thou

Re: [Tutor] Input

2008-01-15 Thread Tiger12506
> Of course I know and use reg. exps., the point of the function is not to > validate input but to force the proper input. So? Are you going to try to tell me that you can force particular input without actually determining if its valid or not first? ;-) Just a thought. ___

Re: [Tutor] Input

2008-01-15 Thread Kent Johnson
Ricardo Aráoz wrote: > _validChars = { > 'X' : > 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' > , '9' : '1234567890' > , '-' : '-1234567890' > , 'A' : > 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' >

Re: [Tutor] Input

2008-01-15 Thread Ricardo Aráoz
Tiger12506 wrote: > Try regular expressions in the re module. This should make this code below > much much simpler. Downside is you have to learn a slightly different > syntax. Upside is - regular expressions are very powerful. > Of course I know and use reg. exps., the point of the function is

Re: [Tutor] Input

2008-01-15 Thread Tiger12506
Try regular expressions in the re module. This should make this code below much much simpler. Downside is you have to learn a slightly different syntax. Upside is - regular expressions are very powerful. > Last week someone had an issue with raw_input() and how to get input for > a number. So

[Tutor] Input

2008-01-15 Thread Ricardo Aráoz
Last week someone had an issue with raw_input() and how to get input for a number. So I remembered my CP/M times and got to think of a little function I had there. The function is lost and my time is scarce but I made a little effort and here you have the results. It has loads of room for improveme

Re: [Tutor] input file encoding

2007-09-11 Thread Tim Michelsen
> Not sure what you mean by "standard encoding" (is this an Ubuntu > thing?) but essentially whenever you're pulling stuff into Python As it was lined out by others I was printing to a linux terminal which had the encoding set to UTF-8. Therefore and for further processing of the data I had to ope

Re: [Tutor] input file encoding

2007-09-11 Thread Kent Johnson
Tim Golden wrote: > Ah, I see. I'm so used to Windows where there is, technically an encoding > for the console window, but you can't really do anything about > it (apart from the awkward chcp) and it isn't really in your face. I > do *use* Linux sometimes, but I don't really think in it :) Actua

Re: [Tutor] input file encoding

2007-09-11 Thread Tim Golden
Kent Johnson wrote: > Tim Golden wrote: >> Not sure what you mean by "standard encoding" (is this an Ubuntu >> thing?) > > Probably referring to the encoding the terminal application expects - > writing latin-1 chars when the terminal expects utf-8 will not work well. Ah, I see. I'm so used to

Re: [Tutor] input file encoding

2007-09-11 Thread Kent Johnson
Tim Golden wrote: > Tim Michelsen wrote: >> Hello, >> I want to process some files encoded in latin-1 (iso-8859-1) in my >> python script that I write on Ubuntu which has UTF-8 as standard encoding. > > Not sure what you mean by "standard encoding" (is this an Ubuntu > thing?) Probably referrin

Re: [Tutor] input file encoding

2007-09-11 Thread Tim Golden
Tim Michelsen wrote: > Hello, > I want to process some files encoded in latin-1 (iso-8859-1) in my > python script that I write on Ubuntu which has UTF-8 as standard encoding. Not sure what you mean by "standard encoding" (is this an Ubuntu thing?) but essentially whenever you're pulling stuff in

[Tutor] input file encoding

2007-09-10 Thread Tim Michelsen
Hello, I want to process some files encoded in latin-1 (iso-8859-1) in my python script that I write on Ubuntu which has UTF-8 as standard encoding. When I use the "print lines_in_myfile" is get some wired symbols. How shold I read those files in or convert their encoding to utf-8? Thanks in ad

Re: [Tutor] Input from and output to a file

2007-02-07 Thread Kent Johnson
govind goyal wrote: > hi, > > 1) I want to read data not from but from a file which is in > specified directory. > 2) I want to redirect my output(which is by default STDOUT) to a file. > > Can anybody suggest these queries? One way to redirect stdin and stdout is just to do it on the comman

[Tutor] Input from and output to a file

2007-02-07 Thread govind goyal
hi, 1) I want to read data not from but from a file which is in specified directory. 2) I want to redirect my output(which is by default STDOUT) to a file. Can anybody suggest these queries? Thanks Regards, Govind ___ Tutor maillist - Tutor@python.

Re: [Tutor] Input mask for console?

2006-09-14 Thread Chris Hengge
The chosen solution was posted by kent... he said getpass.getpass().   As far as a "sample" password... how do I display something I was asking how to hide? =P   >>> Enter Password: "nothing seen here" =D  On 9/14/06, Tiago Saboga <[EMAIL PROTECTED]> wrote: Em Quarta 13 Setembro 2006 21:55, Chris H

Re: [Tutor] Input mask for console?

2006-09-14 Thread Tiago Saboga
Em Quarta 13 Setembro 2006 21:55, Chris Hengge escreveu: > nevermind.. figured it out.. Thanks. Hi Chris, It's not just for you, but I'd like to make a comment. When you write to this list, remember that other people read your questions too, and may be interested in the answers. By the way, I'v

Re: [Tutor] Input mask for console?

2006-09-13 Thread Chris Hengge
I'm assuming I can use that like usrpass = getpass.getpass(raw_input("Password: ")) On Wed, 2006-09-13 at 19:48 -0400, Kent Johnson wrote: > Chris Hengge wrote: > > I need either a way to mask the input from a console, or a method to not > > display the typed characters to the screen. Someone po

Re: [Tutor] Input mask for console?

2006-09-13 Thread Chris Hengge
nevermind.. figured it out.. Thanks. On Wed, 2006-09-13 at 19:48 -0400, Kent Johnson wrote: > Chris Hengge wrote: > > I need either a way to mask the input from a console, or a method to not > > display the typed characters to the screen. Someone point me in the > > right direction? > > getpass.g

Re: [Tutor] Input mask for console?

2006-09-13 Thread Kent Johnson
Chris Hengge wrote: > I need either a way to mask the input from a console, or a method to not > display the typed characters to the screen. Someone point me in the > right direction? getpass.getpass() ? Kent ___ Tutor maillist - Tutor@python.org htt

[Tutor] Input mask for console?

2006-09-13 Thread Chris Hengge
I need either a way to mask the input from a console, or a method to not display the typed characters to the screen. Someone point me in the right direction? Thanks. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] input with default value option

2006-04-11 Thread Alan Gauld
>> With raw_input(), it allows to input value. Can it be used to input value >> with default value option? >> > response = raw_input("Enter some data:") > if not response: response = "default value" This is one of the few places where I do use the short-circuit evaluation trick: val = raw_input

Re: [Tutor] input with default value option

2006-04-10 Thread Danny Yoo
> With raw_input(), it allows to input value. Can it be used to input > value with default value option? Hi Phon, We can build your own function to do this. Bob showed how to set up code so that the default's taken if the user just presses enter in his reply. Let's take a look at it again:

Re: [Tutor] input with default value option

2006-04-10 Thread Bob Gailer
Keo Sophon wrote: > Hi, > > With raw_input(), it allows to input value. Can it be used to input value > with default value option? > response = raw_input("Enter some data:") if not response: response = "default value" ___ Tutor maillist - Tutor@pyt

[Tutor] input with default value option

2006-04-10 Thread Keo Sophon
Hi, With raw_input(), it allows to input value. Can it be used to input value with default value option? Phon ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Input checking [letters or numbers]

2005-12-24 Thread Alan Gauld
> Another newbe question! I use "while True: " to evaluate an > expression, I see that you used while 1: .. what's the diffrence if > any?! Python only provided boolean literal values (True, False) relatively recently. Long time Python programmers, especially those with a C background(*) are used

Re: [Tutor] Input checking [letters or numbers]

2005-12-23 Thread bob
At 11:28 AM 12/23/2005, Panagiotis Atmatzidis wrote: >On 12/23/05, Panagiotis Atmatzidis <[EMAIL PROTECTED]> wrote: > > Hello Dany :-) > > > > On 12/23/05, Danny Yoo <[EMAIL PROTECTED]> wrote: >[...] > > > > > > > > > Hello Bob and Panagiotis, > > > > > > It might be good to make this number-readin

Re: [Tutor] Input checking [letters or numbers]

2005-12-23 Thread Kent Johnson
Panagiotis Atmatzidis wrote: > Hello, > > Can someone provide me with an error checking example about an x > variable that needs to be number only? I used something like: > > def useridf(): > print "" > print "WARNING: If you don't understand why this must be unique, > exit and read th

Re: [Tutor] Input checking [letters or numbers]

2005-12-23 Thread Panagiotis Atmatzidis
On 12/23/05, Panagiotis Atmatzidis <[EMAIL PROTECTED]> wrote: > Hello Dany :-) > > On 12/23/05, Danny Yoo <[EMAIL PROTECTED]> wrote: [...] > > > > > > Hello Bob and Panagiotis, > > > > It might be good to make this number-reading thing a function, just to > > make it easier to reuse (and test!) it.

Re: [Tutor] Input checking [letters or numbers]

2005-12-23 Thread bob
At 11:16 AM 12/23/2005, Panagiotis Atmatzidis wrote: >Hello there, > >Thank you for the prompt response. > >On 12/23/05, bob <[EMAIL PROTECTED]> wrote: >[snip] > > print input("x ; ") > > and enter "Hello world" > > >>> x = input("x: ") >x: hello world >Traceback (most recent call last): > File "

Re: [Tutor] Input checking [letters or numbers]

2005-12-23 Thread Panagiotis Atmatzidis
Yeah works you're right. :-) On 12/23/05, bob <[EMAIL PROTECTED]> wrote: > At 11:16 AM 12/23/2005, Panagiotis Atmatzidis wrote: > >Hello there, > > > >Thank you for the prompt response. > > > >On 12/23/05, bob <[EMAIL PROTECTED]> wrote: > >[snip] > > > print input("x ; ") > > > and enter "Hello wo

  1   2   >