Re: [Tutor] asigning class variables

2010-02-13 Thread Steven D'Aprano
On Sun, 14 Feb 2010 12:08:40 pm the kids wrote: > Hi, my name is John Paul. > > I was trying to define a class but I can't make it asign particular > objects particular variables at their creation. Please help. > > John Paul I don't quite follow what you mean, it is best if you can show example

Re: [Tutor] asigning class variables

2010-02-13 Thread Kent Johnson
On Sat, Feb 13, 2010 at 8:08 PM, the kids wrote: > Hi, my name is John Paul. > > I was trying to define a class but I can't make it asign particular objects > particular variables at their creation.  Please help. It would help to see some details of what you are trying to do. It sounds like you w

Re: [Tutor] json file

2010-02-13 Thread Kent Johnson
On Sat, Feb 13, 2010 at 3:00 PM, Chris Patillo wrote: > Thanks for your response.  i did some research on json.load() and I don't > understand how you extract the data from it.  How do I get just the name and > number from the file? The value returned from json.load() is a Python dictionary. The

[Tutor] asigning class variables

2010-02-13 Thread the kids
Hi, my name is John Paul. I was trying to define a class but I can't make it asign particular objects particular variables at their creation. Please help. John Paul___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] Tutor list as pair progamming plush toy

2010-02-13 Thread Steven D'Aprano
On Sat, 13 Feb 2010 02:33:04 am Mac Ryan wrote: > whenever I get stuck, I begin to write a message to the > list, and in the process of explaining what is the intended behaviour > and outcome of my code, I systematically find the bug by myself. [...] > Does anybody else experience the same? Yes!

tutor@python.org

2010-02-13 Thread Steven D'Aprano
On Sun, 14 Feb 2010 10:58:10 am Alan Gauld wrote: > "spir" wrote > > > PS: in "l>>24 & 255", the & operation is useless, since all 24 > > higher bits are already thrown away by the shift: > > They are not gone however there are still 32 bits in an integer so > the top bits *should* be set to zero.

Re: [Tutor] Not understanding this code example. Help, please.

2010-02-13 Thread Eduardo Vieira
On Sat, Feb 13, 2010 at 7:59 AM, Kent Johnson wrote: > On Fri, Feb 12, 2010 at 11:49 PM, Eduardo Vieira > wrote: >> Hello! I was reading the latest version of Mark Pilgrim's "Dive into >> Python" and am confused with these example about the pluralization >> rules. See http://diveintopython3.org/e

Re: [Tutor] aliasing an imported module

2010-02-13 Thread Steven D'Aprano
On Sat, 13 Feb 2010 10:51:38 am Garry Willgoose wrote: > I want to be able to import multiple instances of a module and call > each by a unique name and it doesn't appear at first glance that > either import or __import__ have what I need. No, such a thing is not officially supported by Python.

tutor@python.org

2010-02-13 Thread Alan Gauld
"spir" wrote PS: in "l>>24 & 255", the & operation is useless, since all 24 higher bits are already thrown away by the shift: They are not gone however there are still 32 bits in an integer so the top bits *should* be set to zero. But glitches can occur from time to time... It is good pract

tutor@python.org

2010-02-13 Thread Alan Gauld
"David Abbott" wrote I am attempting to understand this little program that converts a network byte order 32-bit integer to a dotted quad ip address. def int2ip(l): if MAX_IP < l < 0: raise TypeError, "expected int between 0 and %d inclusive" % MAX_IP return '%d.%d.%d.%d' % (l

tutor@python.org

2010-02-13 Thread spir
On Sat, 13 Feb 2010 23:17:27 +0100 spir wrote: > On Sat, 13 Feb 2010 13:58:34 -0500 > David Abbott wrote: > > > I am attempting to understand this little program that converts a > > network byte order 32-bit integer to a dotted quad ip address. > > > > #!/usr/bin/python > > # Filename : int2ip

tutor@python.org

2010-02-13 Thread spir
On Sat, 13 Feb 2010 13:58:34 -0500 David Abbott wrote: > I am attempting to understand this little program that converts a > network byte order 32-bit integer to a dotted quad ip address. > > #!/usr/bin/python > # Filename : int2ip.py > > MAX_IP = 0xL > ip = 2130706433 > > def int2ip(l

Re: [Tutor] ask

2010-02-13 Thread Kent Johnson
2010/2/13 Shurui Liu (Aaron Liu) : > Yeah, i know. I don't want somebody tell me all the answers of these > assignment directly. I just want to know is there any error in the commands > listed online? My teacher told us there is some, but I cannot find out. He > said we can run them on putty.exe as

Re: [Tutor] ask

2010-02-13 Thread Shurui Liu (Aaron Liu)
Yeah, i know. I don't want somebody tell me all the answers of these assignment directly. I just want to know is there any error in the commands listed online? My teacher told us there is some, but I cannot find out. He said we can run them on putty.exe as soon as we fix the errors. I have found so

Re: [Tutor] Getting caller name without the help of "sys._getframe(1).f_code.co_name" ?

2010-02-13 Thread Luke Paireepinart
On Sat, Feb 13, 2010 at 9:56 AM, patrice laporte wrote: > > Hi, > > Being in an exeption of my own, I want to print the name of the caller, and > I'm looking for a way to have it. > > Could you tell us exactly why you want to do this? It seems sort of strange. Also couldn't you pass the caller a

Re: [Tutor] ask

2010-02-13 Thread Kent Johnson
On Sat, Feb 13, 2010 at 4:08 PM, 刘书睿 wrote: > Here are my assignment about Python, I don't know if anything is wrong. Is > there anybody can help me? > > 1. assignment 9a and 9b hyperlink: > > http://cset.sp.utoledo.edu/cset1100py/cset1100_assign.html#simplepy > > 2. I don't know how to run a prog

[Tutor] ask

2010-02-13 Thread 刘书睿
Here are my assignment about Python, I don't know if anything is wrong. Is there anybody can help me? 1. assignment 9a and 9b hyperlink: http://cset.sp.utoledo.edu/cset1100py/cset1100_assign.html#simplepy 2. I don't know how to run a program in putty.exe, who knows? Cause i don't know the relati

tutor@python.org

2010-02-13 Thread David Abbott
On Sat, 2010-02-13 at 11:32 -0800, Steve Willoughby wrote: On Sat, 2010-02-13 at 13:45 -0600, Wayne Werner wrote: Thanks Steve and Wayne your explanations; HAL (helps a lot) -- David Abbott ___ Tutor maillist - Tutor@python.org To unsubscribe or cha

tutor@python.org

2010-02-13 Thread Wayne Werner
On Sat, Feb 13, 2010 at 12:58 PM, David Abbott wrote: > > I don't understand the l>>24 & 255. > > from the docs; > Right Shift a >> b rshift(a, b) > Bitwise And a & b and_(a, b) > They're binary operations... If you're not familiar, wikipedia or google can find you many sources. In a nutshell

Re: [Tutor] Getting caller name without the help of "sys._getframe(1).f_code.co_name" ?

2010-02-13 Thread patrice laporte
2010/2/13 Kent Johnson > > > >Here is a way to do it using the traceback module. Under the hood it > >is still using implementation details contained in traceback and stack > >frame objects but the public interface in the traceback module should > >be stable. > > >import sys, traceback > > >def w

tutor@python.org

2010-02-13 Thread Steve Willoughby
On Sat, Feb 13, 2010 at 01:58:34PM -0500, David Abbott wrote: > I don't understand the l>>24 & 255. The >> and << operators (when applied to integers) shift the bits left or right a number of positions. The number 5, for example, is 101 in binary, or if you want to picture that as a 16-bit value

tutor@python.org

2010-02-13 Thread David Abbott
I am attempting to understand this little program that converts a network byte order 32-bit integer to a dotted quad ip address. #!/usr/bin/python # Filename : int2ip.py MAX_IP = 0xL ip = 2130706433 def int2ip(l): if MAX_IP < l < 0: raise TypeError, "expected int between 0 an

Re: [Tutor] Getting caller name without the help of "sys._getframe(1).f_code.co_name" ?

2010-02-13 Thread Kent Johnson
On Sat, Feb 13, 2010 at 10:56 AM, patrice laporte wrote: > Being in an exeption of my own, I want to print the name of the caller, and > I'm looking for a way to have it. > > I've found a lot of recipe all of them using what seems to be, according to > me, a not so good trick : all those recipe m

Re: [Tutor] The Order of Imports and install order of modules and other matters (XP vs W7, ...)

2010-02-13 Thread Wayne Watson
Thanks. Sounds like good advice. BTW, I just did some advertising on the AstroPy NG a moment ago for your books. A query for good Py books. On 2/13/2010 8:19 AM, ALAN GAULD wrote: Another question on similar matters. If I write a program and "compile" it for distribution, and a user has 2

[Tutor] Getting caller name without the help of "sys._getframe(1).f_code.co_name" ?

2010-02-13 Thread patrice laporte
Hi, Being in an exeption of my own, I want to print the name of the caller, and I'm looking for a way to have it. I've found a lot of recipe all of them using what seems to be, according to me, a not so good trick : all those recipe make use of sys._getframe(1).f_code.co_name, such as in this exe

Re: [Tutor] The Order of Imports and install order of modules and other matters (XP vs W7, ...)

2010-02-13 Thread Wayne Watson
Thanks, Kent. As of a day ago, I've moved my Python work to W7. For about the last 4 weeks, I've been using XP. Four weeks ago, I moved my mail and browser to W7, so trying to copy out from one PC to the other is a tale of juggling. Next time I have the deprecation and test msgs appear, I'll

Re: [Tutor] The Order of Imports and install order of modules and other matters (XP vs W7, ...)

2010-02-13 Thread ALAN GAULD
> Another question on similar matters. If I write a program and "compile" it > for > distribution, and a user has 2.6 going to be able to execute it. I would like > to > the the compiled program is free of such restrictions. That is, it's an > independent program. I would like to think that

Re: [Tutor] The Order of Imports and install order of modules and other matters (XP vs W7, ...)

2010-02-13 Thread Wayne Watson
Thanks, Alan. Some of what I've derived elsewhere almost sounds like hearsay or is anecdotal. I'm thinking here about forums and the like. However, I just grabbed my Core Python book, and noted than Chun mentions a preferred sequence. Std Lib, Third Party, App specific modules. He cites scoping

Re: [Tutor] Just a Note

2010-02-13 Thread Wayne Werner
On Sat, Feb 13, 2010 at 3:18 AM, Alan Gauld wrote: > > "Randy Raymond" wrote > > By the way, Alan Gauld's emails generate an error in my system. His is >> the only emails I have a problem with so far. At first it tried to open a >> News service. >> > > Interesting. I am using the gmane news se

Re: [Tutor] json file

2010-02-13 Thread Kent Johnson
On Sat, Feb 13, 2010 at 7:21 AM, Chris Patillo wrote: > I need to read in a .json file and write out a file with some of the > information from this file.  I can't figure out how to read the .json file > in.  I know there is a module for this, but I don't understand how it works. > > The file I am

Re: [Tutor] The Order of Imports and install order of modules and other matters (XP vs W7, ...)

2010-02-13 Thread Kent Johnson
On Fri, Feb 12, 2010 at 10:55 PM, Wayne Watson wrote: > There seems to be something of a general consensus in ordering import > statements. Something like standard library imports first. When using tools > like matlablib or tkinter (maybe), must one keep an order among the relevant > imports? I d

Re: [Tutor] Not understanding this code example. Help, please.

2010-02-13 Thread Kent Johnson
On Fri, Feb 12, 2010 at 11:49 PM, Eduardo Vieira wrote: > Hello! I was reading the latest version of Mark Pilgrim's "Dive into > Python" and am confused with these example about the pluralization > rules. See http://diveintopython3.org/examples/plural3.py and > http://diveintopython3.org/generator

[Tutor] json file

2010-02-13 Thread Chris Patillo
I need to read in a .json file and write out a file with some of the information from this file. I can't figure out how to read the .json file in. I know there is a module for this, but I don't understand how it works. The file I am needing to read is like below (except much much larger) {

Re: [Tutor] The Order of Imports and install order of modules and other matters (XP vs W7, ...)

2010-02-13 Thread Alan Gauld
"Wayne Watson" wrote There seems to be something of a general consensus in ordering import statements. Something like standard library imports first. I've never seen anything written down but its true I tend to do that. But its not been a conscious thing... tools like matlablib or tkinter

Re: [Tutor] Not understanding this code example. Help, please.

2010-02-13 Thread Alan Gauld
"Eduardo Vieira" wrote def build_match_and_apply_functions(pattern, search, replace): def matches_rule(word): return re.search(pattern, word) def apply_rule(word): return re.sub(search, replace, word) return (matches_rule, apply_rule) patterns = \ ( ('[sxz]$',

Re: [Tutor] Just a Note

2010-02-13 Thread Alan Gauld
"Randy Raymond" wrote By the way, Alan Gauld's emails generate an error in my system. His is the only emails I have a problem with so far. At first it tried to open a News service. Interesting. I am using the gmane news server but I've not heard of anyone else having problems. Is there