Re: [Tutor] A question about daunting KeyError

2019-07-24 Thread Steven D'Aprano
Hi Taishi, and welcome. On Wed, Jul 24, 2019 at 03:21:03AM +, TAISHI KAWAMURA wrote: [...] > I'm suspecting that Anaconda might keep raising the error, or simply > there are bugs in the codes. However, I can't be sure what the real > cause is. Almost certainly it will be a bug in your code

Re: [Tutor] A question about daunting KeyError

2019-07-24 Thread David L Neil
On 24/07/19 3:21 PM, TAISHI KAWAMURA wrote: Hi tutors on Tutor, I'm Taishi from Japan working in a data analytics team. Currently, I'm trying to analyse purchase data of a fashion brand. However, mysterious KeyErrors started occurring continuously when I was coding, and I haven't been able to

[Tutor] A question about daunting KeyError

2019-07-24 Thread TAISHI KAWAMURA
Hi tutors on Tutor, I'm Taishi from Japan working in a data analytics team. Currently, I'm trying to analyse purchase data of a fashion brand. However, mysterious KeyErrors started occurring continuously when I was coding, and I haven't been able to get that fixed. Although I asked this questio

Re: [Tutor] A Question Regarding the Documentation Format

2017-09-24 Thread Peter Otten
Prateek wrote: > Hi > > Whenever I use help(input) inside Python shell i get the following output: > help(input) > Help on built-in function input in module builtins: > > input(...) > input([prompt]) -> string > > I want to know what the significance of "-> string". I have tried

Re: [Tutor] A Question Regarding the Documentation Format

2017-09-24 Thread Chris Warrick
On 23 September 2017 at 15:15, Prateek wrote: > input(...) > input([prompt]) -> string > > I want to know what the significance of "-> string". I have tried > consulting several books but none of them gave me a clear-cut explanation > for this. This indicates the return type: input() returns

[Tutor] A Question Regarding the Documentation Format

2017-09-24 Thread Prateek
Hi Whenever I use help(input) inside Python shell i get the following output: >>> >>> help(input) Help on built-in function input in module builtins: input(...) input([prompt]) -> string I want to know what the significance of "-> string". I have tried consulting several books but none of

Re: [Tutor] A question about using stdin/out/err vs named files

2014-10-19 Thread Adam Jensen
On 10/18/2014 02:36 PM, George R Goffe wrote: > Hi, > > When you run a python program, it appears that stdin, stdout, and stderr are > opened automatically. > > I've been trying to find out how you tell if there's data in stdin (like when > you pipe data to a python program) rather > than in a

[Tutor] A question about using stdin/out/err vs named files

2014-10-19 Thread George R Goffe
Hi, Wow. Lots of feedback. REALLY GOOD FEEDBACK! This was my first question to this list. Let me clarify my question. I want to use tst.py as follows: tst.py input-file output-file OR cat data-file | tst.py - output-file OR cat data-file | tst.py output-file tst.py input-file output-file works

Re: [Tutor] A question about using stdin/out/err vs named files

2014-10-19 Thread David Rock
* Peter Otten <__pete...@web.de> [2014-10-19 10:05]: > George R Goffe wrote: > > > When you run a python program, it appears that stdin, stdout, and stderr > > are opened automatically. > > > > I've been trying to find out how you tell if there's data in stdin (like > > when you pipe data to a py

Re: [Tutor] A question about using stdin/out/err vs named files

2014-10-19 Thread Alan Gauld
On 18/10/14 19:36, George R Goffe wrote: When you run a python program, it appears that stdin, stdout, and stderr are opened automatically. correct. I've been trying to find out how you tell if there's data in stdin Same way you tell if there's data in any file/stream - you read from it.

Re: [Tutor] A question about using stdin/out/err vs named files

2014-10-19 Thread Peter Otten
George R Goffe wrote: > When you run a python program, it appears that stdin, stdout, and stderr > are opened automatically. > > I've been trying to find out how you tell if there's data in stdin (like > when you pipe data to a python program) rather than in a named input file. > It seems like mo

Re: [Tutor] A question about using stdin/out/err vs named files

2014-10-18 Thread Steven D'Aprano
On Sat, Oct 18, 2014 at 11:36:43AM -0700, George R Goffe wrote: > Hi, > > When you run a python program, it appears that stdin, stdout, and > stderr are opened automatically. > > I've been trying to find out how you tell if there's data in stdin > (like when you pipe data to a python program) r

Re: [Tutor] A question about using stdin/out/err vs named files

2014-10-18 Thread wolfrage8...@gmail.com
Are you planning to pipe data to a python program? If so please specify and you will get more complete answers. Specifically I am thinking you want information pertaining to subprocess in the standard library. https://docs.python.org/3/library/subprocess.html On Sat, Oct 18, 2014 at 2:36 PM, Georg

Re: [Tutor] A question about using stdin/out/err vs named files

2014-10-18 Thread Ben Finney
George R Goffe writes: > When you run a python program, it appears that stdin, stdout, and > stderr are opened automatically. That's true of any program on a POSIX-compliant operating system. > I've been trying to find out how you tell if there's data in stdin > (like when you pipe data to a py

[Tutor] A question about using stdin/out/err vs named files

2014-10-18 Thread George R Goffe
Hi, When you run a python program, it appears that stdin, stdout, and stderr are opened automatically. I've been trying to find out how you tell if there's data in stdin (like when you pipe data to a python program) rather than in a named input file. It seems like most/all the Unix/Linux comm

Re: [Tutor] a question about maxint

2012-10-03 Thread eryksun
On Wed, Oct 3, 2012 at 2:53 PM, Alan Gauld wrote: > > The only times you really need to worry about maxsize is when interfacing to > external non-python code. It's not generally a problem, but if you're on a 32-bit platform, for which sys.maxsize is 2**31 - 1, that sets the maximum length of a se

Re: [Tutor] a question about maxint

2012-10-03 Thread Alan Gauld
On 03/10/12 12:33, eryksun wrote: On Wed, Oct 3, 2012 at 1:28 AM, Katya Stolpovskaya Thank you for you reply, but with "long" I got the same error: from sys import * long Traceback (most recent call last): File "", line 1, in long NameError: name 'long' is not defined I assumed some fam

Re: [Tutor] a question about maxint

2012-10-03 Thread eryksun
On Wed, Oct 3, 2012 at 1:28 AM, Katya Stolpovskaya wrote: > > Thank you for you reply, but with "long" I got the same error: > from sys import * long > > Traceback (most recent call last): > File "", line 1, in > long > NameError: name 'long' is not defined I assumed some familiarity w

Re: [Tutor] a question about maxint

2012-10-02 Thread eryksun
On Tue, Oct 2, 2012 at 12:55 PM, Katya Stolpovskaya wrote: > > I have this error: > from sys import * maxint > Traceback (most recent call last): > File "", line 1, in > maxint > NameError: name 'maxint' is not defined > > > What does it mean and how to deal with it? The "int" type in

Re: [Tutor] a question about maxint

2012-10-02 Thread Mark Lawrence
On 02/10/2012 17:55, Katya Stolpovskaya wrote: Hi all, I have this error: from sys import * maxint Traceback (most recent call last): File "", line 1, in maxint NameError: name 'maxint' is not defined What does it mean and how to deal with it? Thank you in advance, Katya _

Re: [Tutor] a question about maxint

2012-10-02 Thread Peter Otten
Katya Stolpovskaya wrote: > I have this error: > from sys import * maxint > Traceback (most recent call last): > File "", line 1, in > maxint > NameError: name 'maxint' is not defined > > > What does it mean and how to deal with it? You are probably using Python 3 which doesn't have

[Tutor] a question about maxint

2012-10-02 Thread Katya Stolpovskaya
Hi all, I have this error: >>> from sys import * >>> maxint Traceback (most recent call last): File "", line 1, in maxint NameError: name 'maxint' is not defined What does it mean and how to deal with it? Thank you in advance, Katya -- AKA XIAOJIA __

Re: [Tutor] a question about MySQLdb in python

2012-01-10 Thread Peter Otten
贾晓磊 wrote: > hi, all: > > python's version: 2.6. > MySQLdb version: 1.2.3. > > I once encounter with a question like this: > File > "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3-py2.6-linux- x86_64.egg/MySQLdb/connections.py", > > line 36, in defaulterrorhandler > raise erro

[Tutor] a question about MySQLdb in python

2012-01-10 Thread 贾晓磊
hi, all: python's version: 2.6. MySQLdb version: 1.2.3. I once encounter with a question like this: File "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3-py2.6-linux-x86_64.egg/MySQLdb/connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue OperationalError

Re: [Tutor] A question about sys.argv

2011-11-01 Thread Dave Angel
On 11/01/2011 10:19 AM, Jose Amoreira wrote: HiOn Tuesday, November 01, 2011 01:55:18 PM Joel Goldstick wrote: On Tue, Nov 1, 2011 at 9:48 AM, Jefferson Ragot wrote: In a Vista command prompt if I typed this: >>> python somescript.py filename Will sys.argv[1] return a valid path o

Re: [Tutor] A question about sys.argv

2011-11-01 Thread Dave Angel
On 11/01/2011 10:05 AM, Hugo Arts wrote: On Tue, Nov 1, 2011 at 2:48 PM, Jefferson Ragot wrote: In a Vista command prompt if I typed this: >>> python somescript.py filename Will sys.argv[1] return a valid path or just the filename? If it just returns the filename, is there a simpl

Re: [Tutor] A question about sys.argv

2011-11-01 Thread Jose Amoreira
HiOn Tuesday, November 01, 2011 01:55:18 PM Joel Goldstick wrote: > On Tue, Nov 1, 2011 at 9:48 AM, Jefferson Ragot wrote: > > In a Vista command prompt if I typed this: > > >>> python somescript.py filename > > > > Will sys.argv[1] return a valid path or just the filename? > > If it ju

Re: [Tutor] A question about sys.argv

2011-11-01 Thread Hugo Arts
On Tue, Nov 1, 2011 at 2:48 PM, Jefferson Ragot wrote: > In a Vista command prompt if I typed this: > >     >>> python  somescript.py  filename > > Will sys.argv[1] return a valid path or just the filename? > If it just returns the filename, is there a simple way to get the path? > sys.argv c

Re: [Tutor] A question about sys.argv

2011-11-01 Thread Joel Goldstick
On Tue, Nov 1, 2011 at 9:48 AM, Jefferson Ragot wrote: > In a Vista command prompt if I typed this: > > >>> python somescript.py filename > > Will sys.argv[1] return a valid path or just the filename? > If it just returns the filename, is there a simple way to get the path? > > -- > Jef

[Tutor] A question about sys.argv

2011-11-01 Thread Jefferson Ragot
In a Vista command prompt if I typed this: >>> python somescript.py filename Will sys.argv[1] return a valid path or just the filename? If it just returns the filename, is there a simple way to get the path? -- Jefferson B. Ragot ___ Tutor m

Re: [Tutor] A question about the self and other stuff

2009-10-26 Thread Alan Gauld
"Khalid Al-Ghamdi" wrote class Robot: population = 0 def __init__(self, name): self.name=name print ('initializing {0}'.format(self.name)) Robot.population+=1 def __del__(self): '''I'm dying''' print ('{0} is being destroyed!'.format(self.name))

Re: [Tutor] A question about the self and other stuff

2009-10-25 Thread Luke Paireepinart
On Sun, Oct 25, 2009 at 10:10 PM, Luke Paireepinart wrote: > > >> 2- in the final few lines where I assign an object to the class, I notice >> that a parameter was entered in the class name, "Robot(D23)", although when >> defining the class I didn't put any arguments for it. >> > Yes you did, > __

Re: [Tutor] A question about the self and other stuff

2009-10-25 Thread Luke Paireepinart
On Sun, Oct 25, 2009 at 8:06 PM, Khalid Al-Ghamdi wrote: > Hi everybody, > So I'm new to python and have questions about the following code: > > def __init__(self, name): > '''initializes the data''' > self.name=name > print ('initializing {0}'.format(self.name)) > > dr

[Tutor] A question about the self and other stuff

2009-10-25 Thread Khalid Al-Ghamdi
Hi everybody, So I'm new to python and have questions about the following code: class Robot: '''Represents a Robot with a name. Deletes and makes Robots for testing perpuses''' #a var for counting the number of Robots population = 0 def __init__(self, name): '''initializes t

Re: [Tutor] A question about how python handles numbers larger than it's 32 bit limit

2008-09-23 Thread Kent Johnson
On Tue, Sep 23, 2008 at 11:16 AM, John Toliver <[EMAIL PROTECTED]> wrote: > Greetings, > > The book I have says when you anticipate that you will be working with > numbers larger than what python can handle, you place an "L" after the > number to signal python to treat it as a large number. Your b

Re: [Tutor] A question about how python handles numbers larger than it's 32 bit limit

2008-09-23 Thread Steve Willoughby
On Tue, Sep 23, 2008 at 04:24:48PM +0100, Adam Bark wrote: > 2008/9/23 John Toliver <[EMAIL PROTECTED]> > > > Greetings, > > > > The book I have says when you anticipate that you will be working with > > numbers larger than what python can handle, you place an "L" after the > > number to signal py

Re: [Tutor] A question about how python handles numbers larger than it's 32 bit limit

2008-09-23 Thread Adam Bark
2008/9/23 John Toliver <[EMAIL PROTECTED]> > Greetings, > > The book I have says when you anticipate that you will be working with > numbers larger than what python can handle, you place an "L" after the > number to signal python to treat it as a large number. Does this > "treating" of the number

[Tutor] A question about how python handles numbers larger than it's 32 bit limit

2008-09-23 Thread John Toliver
Greetings, The book I have says when you anticipate that you will be working with numbers larger than what python can handle, you place an "L" after the number to signal python to treat it as a large number. Does this "treating" of the number only mean that Python won't try to represent the numbe

Re: [Tutor] a question about iterators

2008-06-17 Thread Kent Johnson
On Tue, Jun 17, 2008 at 1:46 AM, Christopher Spears <[EMAIL PROTECTED]> wrote: > I am confused by this statement: i = iter(a) > > Why do I need to turn 'a' into an iterator? Didn't I already do this when I > constructed the class? Yes, a is already an iterator. > As a test, I tried the fo

[Tutor] a question about iterators

2008-06-16 Thread Christopher Spears
I've been learning about how to implement an iterator in a class from Core Python Programming (2nd Edition). >>> class AnyIter(object): ... def __init__(self, data, safe=False): ... self.safe = safe ... self.iter = iter(data) ... ... def __iter__(self): ... return self

Re: [Tutor] a question about indentation

2006-11-24 Thread Danny Yoo
> I'm fairly new to python, and trying to get used to the indentation. I > just encountered my first problem with it. I wrote the following code: > > for ord in f_ord: >if not ordliste.has_key(ord) : >ordliste[ord] = {} >for word in e_ord: >if ordliste[ord].h

Re: [Tutor] a question about indentation

2006-11-24 Thread arildna
Christopher Arndt wrote: > [EMAIL PROTECTED] schrieb: > >> I suppose there is a good way to do indent whole blocks like this, but I >> haven't found out what it is. Could anybody help me out? >> > > Yes, get a good source code editor that has the ability to (de)indent whole > blocks of cod

Re: [Tutor] a question about indentation

2006-11-24 Thread Christopher Arndt
[EMAIL PROTECTED] schrieb: > I suppose there is a good way to do indent whole blocks like this, but I > haven't found out what it is. Could anybody help me out? Yes, get a good source code editor that has the ability to (de)indent whole blocks of code with one keystroke. This is a must-have for w

[Tutor] a question about indentation

2006-11-24 Thread arildna
Hi, I'm fairly new to python, and trying to get used to the indentation. I just encountered my first problem with it. I wrote the following code: for ord in f_ord: if not ordliste.has_key(ord) : ordliste[ord] = {} for word in e_ord: if ordliste[ord

Re: [Tutor] A question about: Adding seconds to datetime object

2006-11-18 Thread Asrarahmed Kadri
Thanks. It means, you take a datetime object and then using a timedelta object, perform the addition, the language takes care of changing the date if the time crosses midnight. WOW... this makes life a lot easier.. Have a brilliant evening. Best Regards, Asrarahmed Kadri On 11/18/06, Kent John

Re: [Tutor] A question about: Adding seconds to datetime object

2006-11-18 Thread Kent Johnson
Asrarahmed Kadri wrote: > Hi , > > > I have a question: > > Is it possible to add seconds to a datetime object and get the result as > a new datetime object. I mean when we keep adding, for example, 3600 > seconds, the date will get changed after 24 iterations. Is it possible > to carry ou

[Tutor] A question about: Adding seconds to datetime object

2006-11-18 Thread Asrarahmed Kadri
Hi , I have a question: Is it possible to add seconds to a datetime object and get the result as a new datetime object. I mean when we keep adding, for example, 3600 seconds, the date will get changed after 24 iterations. Is it possible to carry out such an operation ? TIA. Best Regards, Asrar

Re: [Tutor] a question about passing values between functions

2006-11-17 Thread Alan Gauld
"kristinn didriksson" <[EMAIL PROTECTED]> wrote > In my understanding, return area in the first routine > makes the value of area an instance of areaCirc No, it simply assigns the value returned by areaCirc to area within . areaCirc assigns 4*(math.pi)*(diameter/2)**2 to its local variable

Re: [Tutor] a question about passing values between functions

2006-11-17 Thread Bob Gailer
kristinn didriksson wrote: > Hello, > I am still wrestling with the concept of values going > between functions. (just starting out)The program > below works seems to work, but here is my question. > In my understanding, return area in the first routine > makes the value of area an instance of area

[Tutor] a question about passing values between functions

2006-11-17 Thread kristinn didriksson
Hello, I am still wrestling with the concept of values going between functions. (just starting out)The program below works seems to work, but here is my question. In my understanding, return area in the first routine makes the value of area an instance of areaCirc and I use areaCirc in the other pr

Re: [Tutor] A question abt exception handling

2006-11-04 Thread Dustin J. Mitchell
import traceback try: something_funny() except: traceback.print_exc() should do the trick for you. Dustin ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] A question abt exception handling

2006-11-04 Thread Asrarahmed Kadri
  Hi Folks,   I want to know how we can print the error message when an exception is generated. I mean "the exact error message that is generated by the python interpreter."   My code is as under:   def check_date(date,num_days):   # this function takes a date and number of days and returns the st

Re: [Tutor] a question about symbol

2006-06-02 Thread Kent Johnson
linda.s wrote: > On 5/28/06, Bob Gailer <[EMAIL PROTECTED]> wrote: >> linda.s wrote: >> When I test the following code, >> I got something like (use 80 as argument): >> 80?F=27?C >> Why '?' appear? >> >> # code >> print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5)) >> >> On my compute

Re: [Tutor] a question about symbol

2006-06-02 Thread linda.s
On 5/28/06, Bob Gailer <[EMAIL PROTECTED]> wrote: > > linda.s wrote: > When I test the following code, > I got something like (use 80 as argument): > 80?F=27?C > Why '?' appear? > > # code > import string, sys > > # If no arguments were given, print a helpful message > if len(sys.argv)==1: > pri

[Tutor] a question about symbol

2006-05-28 Thread ron
When I run this program using your code on Ubuntu Linux, I get: ~$ ./c2f.py 44 44\uF = 7\uC Please notice that the code you have posted has indentation block errors. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protec

Re: [Tutor] a question about symbol

2006-05-28 Thread Bob Gailer
linda.s wrote: When I test the following code, I got something like (use 80 as argument): 80?F=27?C Why '?' appear? # code import string, sys # If no arguments were given, print a helpful message if len(sys.argv)==1: print 'Usage: celsius temp1 temp2 ...' sys.exit(0) # Loop over t

Re: [Tutor] a question about symbol

2006-05-28 Thread Danny Yoo
>> Let's compare the output to what we think is producing it. The very >> last statement in the program looks like the thing we want to watch: >> >> print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5)) >> >> One thing that caught me off guard is the '\260' thing. Can you explain >

Re: [Tutor] a question about symbol

2006-05-28 Thread linda.s
On 5/28/06, Danny Yoo <[EMAIL PROTECTED]> wrote: > > > On Sun, 28 May 2006, linda.s wrote: > > > When I test the following code, > > I got something like (use 80 as argument): > > 80?F=27?C > > Why '?' appear? > > > Hi Linda, > > Let's compare the output to what we think is producing it. The very

Re: [Tutor] a question about symbol

2006-05-28 Thread Danny Yoo
On Sun, 28 May 2006, linda.s wrote: > When I test the following code, > I got something like (use 80 as argument): > 80?F=27?C > Why '?' appear? Hi Linda, Let's compare the output to what we think is producing it. The very last statement in the program looks like the thing we want to watch:

[Tutor] a question about symbol

2006-05-28 Thread linda.s
When I test the following code, I got something like (use 80 as argument): 80?F=27?C Why '?' appear? # code import string, sys # If no arguments were given, print a helpful message if len(sys.argv)==1: print 'Usage: celsius temp1 temp2 ...' sys.exit(0) # Loop over the arguments for i in

Re: [Tutor] A question

2006-02-05 Thread Marilyn Davis
On Sun, 5 Feb 2006, Marilyn Davis wrote: > On Sun, 5 Feb 2006, Bian Alex wrote: > > > How can I get a string from a random file. > > For Example: > > Delete On : Copy > > Owner : Bn > > Personalized: 5 > > PersonalizedName: MyDocuments > > > > I want to get the st

Re: [Tutor] A question

2006-02-05 Thread Marilyn Davis
On Sun, 5 Feb 2006, Bian Alex wrote: > How can I get a string from a random file. > For Example: > Delete On : Copy > Owner : Bn > Personalized: 5 > PersonalizedName: MyDocuments > > I want to get the string after 'Owner' ( In example is 'Bn') > > 'import re' ? Y

Re: [Tutor] A question

2006-02-05 Thread Rinzwind
On 2/5/06, Bian Alex <[EMAIL PROTECTED]> wrote: How can I get a string from a random file. For Example: Del    ete On   :   CopyOwner   :  BnPersonalized: 5PersonalizedName    :  My    Documents   I want to get the string after 'Owner' ( In example is 'Bn')   'import re' ?   Pls help.h

[Tutor] A question

2006-02-05 Thread Bian Alex
How can I get a string from a random file. For Example: Del    ete On   :   CopyOwner   :  BnPersonalized: 5PersonalizedName    :  My    Documents   I want to get the string after 'Owner' ( In example is 'Bn')   'import re' ?   Pls help. ___

Re: [Tutor] a question

2005-07-03 Thread Alan G
t; <[EMAIL PROTECTED]> To: Sent: Sunday, July 03, 2005 8:10 AM Subject: [Tutor] a question when I type sys.ps2 after import sys, I got the message like: Traceback (most recent call last): File "", line 1, in -toplevel- sys.ps2 AttributeError: 'module' object has n

Re: [Tutor] a question

2005-07-03 Thread Kent Johnson
Xinyue Ye wrote: > when I type sys.ps2 after import sys, > I got the message like: > Traceback (most recent call last): > File "", line 1, in -toplevel- > sys.ps2 > AttributeError: 'module' object has no attribute 'ps2' > why does it happen? >From the docs: ps1 ps2 Strings specifying the pr

[Tutor] a question

2005-07-03 Thread Xinyue Ye
when I type sys.ps2 after import sys, I got the message like: Traceback (most recent call last): File "", line 1, in -toplevel- sys.ps2 AttributeError: 'module' object has no attribute 'ps2' why does it happen? ___ Tutor maillist - Tutor@python.org h