Re: [Tutor] if statement

2011-06-08 Thread Steven D'Aprano
Matthew Brunt wrote: i'm very new to python (currently going through a python for beginners book at work to pass the time), and i'm having trouble with an if statement exercise. basically, i'm creating a very simple password program that displays Access Granted if the if statement is true. the

Re: [Tutor] Python Beginners

2011-06-08 Thread Steven D'Aprano
Vincent Balmori wrote: Hello. Right now I am learning the python language through Python Programming for the Absolute Beginner 3rd Edition. I am having trouble with one question in Ch. 4 #3, which says Improve 'WordJumble so that each word is paired with a hint. The player should be able to

Re: [Tutor] Python Beginners

2011-06-08 Thread Steven D'Aprano
Dave Angel wrote: On 01/-10/-28163 02:59 PM, Vincent Balmori wrote: Hello. Right now I am learning the python language through Python Programming for the Absolute Beginner 3rd Edition. I am having trouble with one question in Ch. 4 #3, which says Improve 'WordJumble so that each word is paired

Re: [Tutor] Copying a mutable

2011-06-08 Thread Steven D'Aprano
Válas Péter wrote: Being one of the purposes of Python to be a simple educational language, I want to make this simple to a beginner who does care. :-) Here is a piece of code, Python 3.1.2, a small game with a list and a tuple: li=[3,4] id(li) 13711200 la=li id(la) 13711200 You can make

Re: [Tutor] lxml.html

2011-06-08 Thread Steven D'Aprano
nitin chandra wrote: Hello Every One, doc = lxml.html.parse('/home/dev/wsgi-scripts/index.py').getroot() name = doc.forms[0].fields['name'] html = 'name is ' html += name ERROR [Wed Jun 08 20:29:51 2011] [error] [client 192.168.1.9] Traceback (most recent

Re: [Tutor] lxml.html

2011-06-08 Thread Steven D'Aprano
nitin chandra wrote to me off-list. I've taken the liberty of returning the conversation to the mailing list. Hi, ERROR [Wed Jun 08 20:29:51 2011] [error] [client 192.168.1.9] Traceback (most recent call last): What is all this extraneous date/error/ip address nonsense in the traceback?

Re: [Tutor] Lists

2011-06-10 Thread Steven D'Aprano
Vincent Balmori wrote: I'm stuck on two problems from the Absolute Beginners book. The first is simple. I am trying to print all the words in the list in random order without repeats, but it always shows None for some reason. #Program prints list of words in random order with no repeats

Re: [Tutor] telnet connection question

2011-06-10 Thread Steven D'Aprano
Rayon wrote: HI All, Is there any way that I can use python telnetlib to connect to a telnet session. It would be a pretty rubbish telnet library if it didn't let you make telnet connections. I don't understand why you are asking this question, since you have successfully made

Re: [Tutor] Lists

2011-06-10 Thread Steven D'Aprano
Piotr Kamiński wrote: Could you please refrain from presenting your *religious* convictions in this list: the notions you believe in as well as the ones that you believe are false? This is a *technical* list, as I understand it, solely dedicated to the technical side of teaching the *Python*

Re: [Tutor] STUPID telnet connection question

2011-06-11 Thread Steven D'Aprano
davidheise...@gmail.com wrote: I think Steven and Alan misunderstood the Rayon's question. Rayon is using his telnet script to pass commands to a device ONE AT A TIME. Then he breaks the connection and reconnects for the next command.. He is asking how to open a telnet connection, pass

Re: [Tutor] dummy, underscore and unused local variables

2011-06-11 Thread Steven D'Aprano
Tim Johnson wrote: Consider the following code: for i in range(mylimit): foo() running pychecker gives me a Local variable (i) not used complaint. If I use for dummy in range(mylimit): ## or for _ in range(mylimit): I get no complaint from pychecker. I would

Re: [Tutor] Saving data as jpg file

2011-06-11 Thread Steven D'Aprano
Johan Geldenhuys wrote: Hi, I have a Axis IP camera that I can send a HTTP command to and the data returned is the jpg image. When I get this data, I want to save it as a .jpg file, but I think my encoding is not correct, because the image is all distorted. Are you sure that the data

Re: [Tutor] Floating Point Craziness

2011-06-12 Thread Steven D'Aprano
Ryan Strunk wrote: Hi everyone, I'm designing a timeline. When the user presses the right arrow, 0.1 is added to the current position. The user can add events to the timeline, and can later scroll back across those events to see what they are. But something I absolutely don't understand is

Re: [Tutor] [OT] Re: Floating Point Crazines

2011-06-12 Thread Steven D'Aprano
Robert Sjoblom wrote: * Or you just get used to the fact that some numbers are not exact in floating point. This got me thinking. How many decimal places do you need to accurately, say, aim a laser somewhere in a 180 degree arc accurately enough to hit a dime on the surface of the moon? Alan

Re: [Tutor] Creating Reports in Python

2011-06-12 Thread Steven D'Aprano
Mark Cowley - FlexSystems wrote: Hi I am looking for recommendations for Report writers under Python. Current reports are in Crystal reports if that is an option. Any suggestions are welcome. You might get more responses on the main python mailing list, python-l...@python.org, or

Re: [Tutor] step value

2011-06-13 Thread Steven D'Aprano
Vincent Balmori wrote: I am stuck on a question for Absolute Beginner's. I googled this and there have been others who have not understood the question and I am also not clear on the question he is asking. This function is a part of a tic tac toe program.Improve the function ask_number() so

Re: [Tutor] python-gobject for debian4

2011-06-13 Thread Steven D'Aprano
Ganesh Kumar wrote: Hi Guys. I want python-gobject package for debian4 (etch). But unfortunately removed for debian4 depository . This is not a Python problem. It is especially not a problem about learning Python. You should ask this at either a Debian forum or on the python-gobject

Re: [Tutor] Floating Point Craziness

2011-06-13 Thread Steven D'Aprano
Nathan wrote: who can tell me how to unsubscribe the message. Look at the bottom of every single message to the mailing list, and you will see this: Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Steven

Re: [Tutor] Floating Point Craziness

2011-06-13 Thread Steven D'Aprano
Válas Péter wrote: 2011/6/12 Brett Ritter swift...@swiftone.org Okay fine, so 1024 stored as a number only requires 10 bits (binary digits) to store, Actually, 11. :-) I see your smiley, but actually more than that. Due to the way computers are designed, numbers are stored in fixed

Re: [Tutor] Medical Decision-Making Question

2011-06-13 Thread Steven D'Aprano
Fred G wrote: Hello-- I'm a pre-med student interested in decision-making as applied to medical decisions. I am trying to build a medical decision-making algorithm and am pretty stuck on a few things. Essentially what you want is to build an expert system. I don't want to discourage you,

Re: [Tutor] Floating Point Craziness

2011-06-13 Thread Steven D'Aprano
Kĩnũthia Mũchane wrote: On 06/12/2011 08:13 PM, Steven D'Aprano wrote: Unfortunately, many common fractions cannot be written exactly in binary. You're probably familiar with the fact that fractions like 1/3 cannot be written exactly in decimal: 1/3 = 0.... goes on forever Does

Re: [Tutor] Break stament issue

2011-06-14 Thread Steven D'Aprano
Susana Iraiis Delgado Rodriguez wrote: Hello members! I'm doing a script that needs to loop to get some information, in order to do that I'm using modules from OGR and Mapnik. These to get data from shapefiles, but some of the files have 0 elements, I wrote a line to validate it, but it hasn't

Re: [Tutor] Communicating Between Programs Using Raw Inputs

2011-06-14 Thread Steven D'Aprano
Jacob Bender wrote: Dear Python Tutors, I was wondering how to break into my one program I made using brute force methods. Here's the code: password = Helloworld try= raw_input(What's the password?) while try != password: try = raw_input(Incorrect, what's the password?) I know how to do

Re: [Tutor] Already Initialized Object Inheritance?

2011-06-15 Thread Steven D'Aprano
WolfRage wrote: Unfortunately I am not able to inherit stdscr using that method. As Python returns with an error stating that stdscr is not defined. This error is returned at run time and by the compiler prior to actual execution. If you would like I can write a quick example that will generate

Re: [Tutor] step value

2011-06-15 Thread Steven D'Aprano
Vincent Balmori wrote: The question to that code I am trying to solve is Improve the function ask_number() so that the function can be called with a step value. Make the default value of step 1. You need to be able to tell ask_number what step function you want to use. So it isn't

Re: [Tutor] using python to write web page

2011-06-15 Thread Steven D'Aprano
naheed arafat wrote: Got a question in this context. If i would like to edit an html file. suppose i want to edit the values of href tags or the img tags, what should i do? This question is more general than just editing HTML files. The same question, and answer, applies to editing *any* file

Re: [Tutor] Tutor Digest, Vol 88, Issue 56

2011-06-16 Thread Steven D'Aprano
WolfRage wrote: CODE BELOW #!/usr/bin/python3 With this method I can make the class Screen become stdscr but if I refernce any of the new methods or properties the applications promptly fails and notifies me that the attribute does not exist. That's because it doesn't exist. stdscr

Re: [Tutor] Step Value

2011-06-16 Thread Steven D'Aprano
Vincent Balmori wrote: Okay, I think I understand it better for the quesiton: Improve the function ask_number() so that the function can be called with a step value. Make the default value of step 1. Here is the improved function and the human_move function that calls it later on. The thing I

Re: [Tutor] File parsing

2011-06-16 Thread Steven D'Aprano
Neha P wrote: Thanks James I guess i have to use the same code for text in yellow... seems like ther's no other way... What code in yellow? I see no code in yellow. This is email, don't assume people can see colours. They may have HTML blocked or turned off (very important for security,

Re: [Tutor] Seattle PyCamp 2011

2011-06-17 Thread Steven D'Aprano
Noah Hall wrote: Just a note, but are these questions jokes? Know how to use a text editor (not a word processor, but a text editor)? Know how to use a browser to download a file? Know how to run a program installer? If not, then I'd consider removing them. This isn't 1984. I think the

Re: [Tutor] Step Value

2011-06-17 Thread Steven D'Aprano
Vincent Balmori wrote: Here is my updated code. As simple as this may be, I am a little lost again. I appreciate the help and explanations to try to push me to get this on my own, but at this point (especially after one week) this is when me being given the answer with an explanation will help

Re: [Tutor] Break stament issue

2011-06-17 Thread Steven D'Aprano
Susana Iraiis Delgado Rodriguez wrote: Hello members!! Steven, I already changed the settings in the IDE to avoid the trouble when I type the code. In the other hand I added the pass statement so the script keep working even though it finds an error, but the scripts ignore the pass statement.

Re: [Tutor] Medical Decision-Making Question

2011-06-17 Thread Steven D'Aprano
Fred G wrote: Thanks guys for all the feedback. re Jim's comments: I completely agree that the difference b/t slight fever and returning fever, etc will pose some problems. My hunch is that initially I'll just do something like make fever be the only one for now Any qualitative rating system

Re: [Tutor] Closing triple quotation marks.

2011-06-18 Thread Steven D'Aprano
Lisi wrote: [...] Fair enough. the closing quotation marks are not there. But when they _are_ there, i.e. when that stanza reads: target.write line1\nline2\nline3\n This is not the problem, but I just thought I'd mention that it's a bit silly to go to the trouble of using newline escape

Re: [Tutor] Closing triple quotation marks.

2011-06-18 Thread Steven D'Aprano
Lisi wrote: But I still can't write to the file. If I do: target.write(line1) The value of the variable line1 is written to the file. But if I put the three variables into the write command, what gets printed is the name of the variables, not their values. I am clearly still doing

Re: [Tutor] using configobj package to output quoted strings

2011-06-18 Thread Steven D'Aprano
Alex Hall wrote: Hello all, I am using the configobj package to handle a ridiculously simple ini What's configobj? import configobj Traceback (most recent call last): File stdin, line 1, in module ImportError: No module named configobj It's not in the 3.1 standard library. Is it a

Re: [Tutor] using configobj package to output quoted strings

2011-06-18 Thread Steven D'Aprano
Alex Hall wrote: Still, it is odd (well, to me at least) that when I write the string to the file with no quotes, I get no quotes, but using double quotes in the string's value gives me both single and double quotes. Sounds to me like bad design on the part of configobj, but perhaps I'm

Re: [Tutor] nitinchandra rubbish on list

2011-06-19 Thread Steven D'Aprano
Válas Péter wrote: Each time I send a message to this list, I get an autoreply like this. No, I won't add myself to any stupid guestlists to use a public list. Could a list moderator please show this user the exit? I've been sending many lists to this list, and haven't received any such

Re: [Tutor] nitinchandra rubbish on list

2011-06-19 Thread Steven D'Aprano
nitin chandra wrote: Hello All, MY Sincerest APOLOGIES i had joined a a mail box management services... But unfortunately It started interfering with my Gmail mail box. Thanks for fixing this! -- Steven ___ Tutor maillist -

Re: [Tutor] decorators

2011-06-23 Thread Steven D'Aprano
Robert wrote: Is there a good tutorial out there somewhere about decorators? Google doesn't bring up much. Define good :) I'm interested in what you think about this article: http://www.artima.com/weblogs/viewpost.jsp?thread=240808 Personally, I think it's filled with jargon that will be

Re: [Tutor] decorators

2011-06-24 Thread Steven D'Aprano
Prasad, Ramit wrote: Excellent explanation Steven; I understood the mechanical basics but this has made the reason behind it a lot clearer. If test_argument is only being passed the function how does it have access to the arguments? It doesn't. There are three functions involved. The first

Re: [Tutor] Conceptual Question About Use of Python for Employee Training Program

2011-06-25 Thread Steven D'Aprano
Adam Carr wrote: Good Morning: I am very new to Python but I am enjoying the learning process. I have a question about the application of Python to a problem at the industrial business where I work. My two main questions are: 1. Can Python be used to achieve the goals of the possible

Re: [Tutor] Efficiency

2011-06-25 Thread Steven D'Aprano
naheed arafat wrote: 1) zip('How are you?'.split(' ')[::-1],'i am fine.'.split(' ')) [('you?', 'i'), ('are', 'am'), ('How', 'fine.')] map(lambda i,j:(i,j),'How are you?'.split(' ')[::-1],'i am fine.'.split(' ')) [('you?', 'i'), ('are', 'am'), ('How', 'fine.')] Which one has better

Re: [Tutor] Efficiency

2011-06-26 Thread Steven D'Aprano
wrote: On Sat, Jun 25, 2011 at 9:42 PM, Steven D'Aprano st...@pearwood.infowrote: [...] Define efficiency. Do you mean: - most efficient for the programmer to write? - easiest to read? - fastest for the compiler to compile? - uses the smallest number of characters in source code? - takes up

Re: [Tutor] Defining a format string

2011-06-26 Thread Steven D'Aprano
Lisi wrote: In the following excerpt from a program in the book I am following: print If I add %d, %d, and %d I get %d. % ( my_age, my_height, my_weight, my_age + my_height + my_weight) is % ( my_age, my_height, my_weight, my_age + my_height + my_weight) the/a format

Re: [Tutor] The Card Game

2011-06-30 Thread Steven D'Aprano
Christopher King wrote: I would go with __cmp__ which covers them all. 1 for greater, 0 for equal, -1 for less than. So-called rich comparisons using __lt__, __gt__, etc. have been preferred since Python 2.1. The major advantage of them is that they can be used for more complicated data

Re: [Tutor] 2to3 conversion

2011-07-01 Thread Steven D'Aprano
Zubin Mithra wrote: Hey everyone, I was running 2to3 on a particular file and I got the following traceback( http://paste.pocoo.org/show/223468/). For short amounts of text, such as a traceback, please don't use a paste bin, just copy it into your post. Some people are reading mail at a

Re: [Tutor] 2to3 conversion

2011-07-01 Thread Steven D'Aprano
Steven D'Aprano wrote: Zubin Mithra wrote: Hey everyone, I was running 2to3 on a particular file and I got the following traceback( http://paste.pocoo.org/show/223468/). For short amounts of text, such as a traceback, please don't use a paste bin, just copy it into your post. *blinks

Re: [Tutor] Limit raw_input to hundredth decimal point

2011-07-01 Thread Steven D'Aprano
Ryan Kirk wrote: Is there a way to limit raw_input to the hundredth decimal point? No. raw_input is a tool that does one thing: it collects input from the user. It doesn't understand numbers, check for decimal places, check the input for spelling errors, or anything else. It's a hammer, not

Re: [Tutor] problem reading script

2011-07-01 Thread Steven D'Aprano
Lisi wrote: I am supposed to be looking at scripts on-line, reading them and making sure that I understand them. I think taht most of teh things I can't make more than a guess at, are modules taht I don't know, and I can mostly make them out. But the unpaired double quotation mark, , in the

Re: [Tutor] The Card Game

2011-07-01 Thread Steven D'Aprano
Christopher King wrote: Sorry, I haven't upgraded to 3 yet. No need to apologise for that! Python 2.7 will be around a long time yet. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] problem reading script

2011-07-01 Thread Steven D'Aprano
Lisi wrote: On Friday 01 July 2011 14:26:07 Steven D'Aprano wrote: If they look the same to you, then you need to increase your font size, change to a programmers font, or possible clean your glasses :) Thanks for the reply, Steven. Suggestions for a programmers font gratefully received

Re: [Tutor] Algorithm for sequence matching

2011-07-02 Thread Steven D'Aprano
ANKUR AGGARWAL wrote: Hey I am looking for an algo for the largest sequence search in the two list. Example : list a accepts some say 'm' numbers. list b accept says 'n' numbers. I want to look for the largest same sequence between the two list and then display it. I tried out but failed to do

Re: [Tutor] problem with reading dns query

2011-07-02 Thread Steven D'Aprano
preetam shivaram wrote: I have got a very simple idea in mind that i want to try out. Say i have a browser, chrome for instance, and i want to search for the ip of the domain name, say `www.google.com`. I use windows 7 and i have set the dns lookup properties to manual and have given the address

Re: [Tutor] Using a dict value in the same dict

2011-07-05 Thread Steven D'Aprano
Válas Péter wrote: So the trick is to define the dictionary in separate sessions, not at once. No. value = 42 my_dict = {'a': value, 'b': value, 'c': 23, 'd': value, 'e': 97} will work fine too. -- Steven ___ Tutor maillist -

Re: [Tutor] What algorithm suits here

2011-07-13 Thread Steven D'Aprano
Amit Sethi wrote: I have a list of dictionaries in this form. { message : xyz parent : 23 id : 25 } or { message : abc parent : None id : 25 } { message : cde parent : 28 id : 32 } { message : cde parent : 23 id : 35 } I want to make seperate the lists such that messages in same thread(

Re: [Tutor] Get file last user

2011-07-13 Thread Steven D'Aprano
Susana Iraiis Delgado Rodriguez wrote: Hello list!!! I want to get the last user who accessed to a file, I already have the way to know who owns the file, but I really need to get this information. To get file user I'm using: os.environ.get(USERNAME) and to get the machine host:

Re: [Tutor] Descriptors and type declaration order

2011-07-14 Thread Steven D'Aprano
Knacktus wrote: Hi guys, I've got the following (not working) code: [...] The problem is that the descriptors are created when the module is evaluated. But at this time the class BaseItem is not known yet. Any ideas? Yes -- don't do that. What are you actually trying to accomplish?

Re: [Tutor] Hello World in Python without space

2011-07-15 Thread Steven D'Aprano
Richard D. Moores wrote: But that makes me wonder if there isn't a simpler way to do it with Python -- to delete the contents of a file without deleting the file? Opening a file for writing will flush the contents. open(filename, 'w') will do it, taking advantage of Python's garbage

Re: [Tutor] Filling orders FIFO

2011-07-15 Thread Steven D'Aprano
Charles John wrote: Hi I am new to python and was wondering what the best way to create an order(bid and offer) queue, then match a bid and offer so that if bid==offer, creates a filled order FIFO in python cgi using mysql? Does anybody have any ideas? It would be greatly appreciated. The

Re: [Tutor] IDLE/tk in 10.6

2011-07-15 Thread Steven D'Aprano
Luke Thomas Mergner wrote: [...] I'd like to try IDLE but there appears to be a known bug with 10.6's version of ActiveTCL. I've installed a newer version 8.5 via their website, but this has not fixed the problem. The module tkinter is still unable to load. Since both python and activeTCL

Re: [Tutor] how to add directory to python search list

2011-07-17 Thread Steven D'Aprano
Surya P.K. Kasturi wrote: can you tell me in detail how to do this. I am new to linux. this being: On Sat, Jul 16, 2011 at 11:48 AM, Alan Gauld alan.ga...@btinternet.comwrote: You need to add the folder to your PYTHONPATH environment variable. You usually do this your .login or .profile

Re: [Tutor] Filling orders FIFO

2011-07-17 Thread Steven D'Aprano
has a good solution to the problem, by all means show us how you would use it. P.S. we prefer that you don't top-post on this mailing list. It makes it easier to understand replies if they follow what they are replying to, rather than come before. Steven. 2011/7/16 Steven D'Aprano st

Re: [Tutor] Homework problem

2011-07-20 Thread Steven D'Aprano
Ken Baclig wrote: Hi, I'm trying to make a function that receives text (a string) as an argument and returns the same text (as string), but with 1 added to each word that is a number. What counts as a number? In the string: Hello world 1234 ham spam which of these do you expect to get

Re: [Tutor] questions on encoding

2011-07-20 Thread Steven D'Aprano
Albert-Jan Roskam wrote: Hi, I am looking for test data with accented and multibyte characters. I have found a good resource that I could use to cobble something together (http://www.inter-locale.com/whitepaper/learn/learn-to-test.html) but I was hoping somebody knows some ready resource. I

Re: [Tutor] little/big endian was Re: what is 'doubleword alignment'?

2011-07-21 Thread Steven D'Aprano
Dave Angel wrote: Little-endian is the method used by the Intel processor (such as the Pentium). Big-endian is the system used by most network protocols, as well as the 68000 and many other processors. There used to be mainframes with various forms of middle-endian layouts. Fortunately

Re: [Tutor] Avoiding reauthentication to web services?

2011-07-21 Thread Steven D'Aprano
Ryan on the Beach wrote: Hello. I am trying to write a python program to control a lighting controller through it's rest interface. It requires ssl and basic authentication. I have been successful using urllib2. However, the authentication takes a very long time on the controller so

Re: [Tutor] Don't understand this class/constructor call syntax

2011-07-22 Thread Steven D'Aprano
dave wrote: class transmit_path(gr.top_block) [...] self.packet_transmitter = ieee802_15_4_pkt.ieee802_15_4_mod_pkts(self, spb=self._spb, msgq_limit=2) This calls the ieee802_15_4_mod_pkts initializer (not a constructor -- see below) with one

Re: [Tutor] Copying Variables

2011-07-23 Thread Steven D'Aprano
Ryan Strunk wrote: Hello everyone, How can I make two copies of a dictionary that don't point to the same location in memory? My plan is to generate d1 and make d2 a copy of d1. After the user modifies d1 I want him/her to be able to return to the initial dictionary (d2) values. I tried: d1 =

Re: [Tutor] Don't understand this class/constructor call syntax

2011-07-24 Thread Steven D'Aprano
dave wrote: Thank you for the two explanations. I think I have a good idea of what is going on now with the arguments and keyword arguments. My only remaining question is the pad_for_usrp argument. The default value is True so I thought it was a boolean and couldn't have anything to do with

Re: [Tutor] Basic program question

2011-07-24 Thread Steven D'Aprano
Alexander Quest wrote: Hello- I am running Python v 3.1.1. As an exercise, I wrote a simple coin flipper program, where the computer flips a coin 100 times and then prints out the number of heads and tails. My program crashes immediately if I run it normally through the command line, but if I go

Re: [Tutor] Running Python in script vs. Idle

2011-07-24 Thread Steven D'Aprano
brandon w wrote: I wrote this in Idle and ran it in Idle and it worked fine. [...] Then I try to run it from a script in Gnome-terminal and it does not run. I do not get output. I have to add print. to get any output like this: [...] What is the difference? This is what was confusing me

Re: [Tutor] Running Python in script vs. Idle

2011-07-24 Thread Steven D'Aprano
brandon w wrote: Thank you. I understand that this ( x = 1+2 ) assigns a variable to x and will not print in Idle, but how would I get the 'class' that I created to run from the script like it does in Idle? Will I have to put print before everything I have to print? Yes. If you want

Re: [Tutor] Don't understand this class/constructor call syntax

2011-07-24 Thread Steven D'Aprano
dave wrote: I was dimly aware of the functioning of booleans, but I see now that it doesn't specify an actual boolean type. Still, the code confuses me. Is the usage of pad_for_usrp consistent with it being treated as a boolean? Why would the entire self reference be transmitted then?

Re: [Tutor] Don't understand this class/constructor call syntax

2011-07-26 Thread Steven D'Aprano
dave wrote: Is it even possible to replace the implicit self argument of the initializer by passing something else? If so, what would be the syntax. Yes, by calling an unbound method. Consider this class: class MyClass: def func(self, x): return x+1 When you run this code,

Re: [Tutor] Object Management

2011-07-27 Thread Steven D'Aprano
Alexander wrote: Hello everyone. I'm having trouble wrapping my mind around a project I'm working on. My goal is to create a program that manages (allows its users to manipulate, search by criteria and edit) objects. There is one type of object, for example I'll say it's a car. This is called

Re: [Tutor] shlex parsing

2011-07-27 Thread Steven D'Aprano
Karim wrote: Hello All, I would like to parse this TCL command line with shlex: '-option1 [get_rule A1 B2] -option2 $VAR -option3 TAG' And I want to get the splitted list: ['-option1', '[get_rule A1 B2]', '-option2', '$VAR', '-option3', 'TAG'] Then I will gather in tuple 2 by 2 the

Re: [Tutor] Assigning range

2011-07-27 Thread Steven D'Aprano
Alexander Quest wrote: Does anyone know how to assign a certain numerical range to a variable, and then choose the number that is the middle of that range? For example, I want to assign the variable X a range between 1 and 50, and then I want to have the middle of that range (25) return with

Re: [Tutor] Is it bad practise to write __all__ like that

2011-07-28 Thread Steven D'Aprano
Karim wrote: Hello, __all__ = 'api db input output tcl'.split() Yes, it's lazy, no it is not bad practice. I wouldn't do it myself, but I wouldn't object if somebody else did it. -- Steven ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] Sum files' size

2011-07-28 Thread Steven D'Aprano
Susana Iraiis Delgado Rodriguez wrote: I want to get the size of 3 files. I already completed this step. Then I need to sum the 3 results I got. In order to do it I have the next code: [...] #Finally I want to sum the 3 terms: total = kb+kb2+kb3 But the output I got is :

Re: [Tutor] Running files from command prompt

2011-07-28 Thread Steven D'Aprano
Alexander Quest wrote: To clarify, the particular file that was giving me trouble was the basic hello world file. The original code on line 29 read as such: print 'Hello', name When I ran C:\google-python-exercises python hello.py, it gave me an error on that line (line 29), but when I changed

Re: [Tutor] About the Mailing List

2011-07-28 Thread Steven D'Aprano
Jordan wrote: How do I see what in the mailing list has already been responded too, before it sends me the digest? For instance I wanted to respond to one of the questions, but seeing that the time was almost two hours ago. I am sure someone has already responded. Where could I check to see if

Re: [Tutor] Urllib Problem

2011-07-29 Thread Steven D'Aprano
George Anonymous wrote: I am trying to make a simple programm with Python 3,that tries to open differnet pages from a wordlist and prints which are alive.Here is the code: from urllib import request fob=open('c:/passwords/pass.txt','r') x = fob.readlines() for i in x:

Re: [Tutor] Reading .gz files

2011-07-29 Thread Steven D'Aprano
Hanlie Pretorius wrote: [code] import gzip f1 = 'GSMaP_MVK+.20050101.00.0.1deg.hourly.v484.gz' f2 = ''text.txt.gz' if1 = gzip.open(f1, 'rb') if2 = gzip.open(f2,'rb') try: print if1.read() print 'done with f1' print if2.read() print 'done with f2' finally: if1.close()

Re: [Tutor] Reading .gz files

2011-07-29 Thread Steven D'Aprano
Oh, I forgot to say something else... Hanlie Pretorius wrote: f1 = 'GSMaP_MVK+.20050101.00.0.1deg.hourly.v484.gz' f2 = ''text.txt.gz' if1 = gzip.open(f1, 'rb') if2 = gzip.open(f2,'rb') try: print if1.read() print 'done with f1' Once you've read the file once, the file pointer is at

Re: [Tutor] How to make tkMessage function to have duration

2011-07-30 Thread Steven D'Aprano
Emeka wrote: Hello All, Say I have the below(code), I would want the message to last say 30 seconds and afterwards disappear. I won't want the user to be the one to enable it to disappear. Basically, what I want is to be able to show the user some message , and after some seconds, the

Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Steven D'Aprano
Sandip Bhattacharya wrote: Generally, converting slashes manually should be kept at a minimum. You should be using library functions as much as possible. The experts here can correct me here, but this is a roundabout way I would be doing this: str.replace('\\', '/') is a perfectly fine

Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Steven D'Aprano
Richard D. Moores wrote: File c:\P32Working\untitled-5.py, line 2 return path.replace('\', '/') ^ SyntaxError: EOL while scanning string literal Others have already told you how to solve the immediate problem (namely, escape the backslash), but I'd like to

Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Steven D'Aprano
Sergey wrote: Gotcha! http://pymon.googlecode.com/svn/tags/pymon-0.2/Internet/rsync.py 231-239 strings ## code ## def convertPath(path): # Convert windows, mac path to unix version. separator = os.path.normpath(/) if separator != /: path =

Re: [Tutor] Accessing Specific Dictionary items

2011-08-01 Thread Steven D'Aprano
Mike Nickey wrote: The input being used is through pygeoip. Using this I am pulling the data by IP and from what I am reading this populates as a dictionary. Here is some of the output that I can show currently [{'city': 'Buena Park', 'region_name': 'CA', 'area_code': 714}, {'city':

Re: [Tutor] When to use def __init__ when making a class?

2011-08-02 Thread Steven D'Aprano
brandon w wrote: I have two questions: 1) When should I use def __init__(self): when I create a class? Whenever you need something to happen when you create an instance. 2) Would these two classes have the same effect? Technically, no, but in practice, you would find it hard to see the

Re: [Tutor] Puzzled again

2011-08-03 Thread Steven D'Aprano
. By Steven D'Aprano 07/31/2011 on Tutor list path = r'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf' Are you aware that this is not a raw string? It's wrapped inside another non-raw string, so it is merely a sub-string containing the letters r single-quote C colon backslash-U etc

Re: [Tutor] Puzzled again

2011-08-03 Thread Steven D'Aprano
Steven D'Aprano wrote: Richard D. Moores wrote: Puzzled again. Why the error. Line 36 is the line just above import os.path. I have many other functions in mycalc.py with examples formatted exactly the same way. def convertPath(path): Given a path with backslashes, return that path

Re: [Tutor] Puzzled again

2011-08-03 Thread Steven D'Aprano
Richard D. Moores wrote: But here's a try using the regular command line: C:\Windows\System32python Python 3.2.1 (default, Jul 10 2011, 20:02:51) [MSC v.1500 64 bit (AMD64)] on win32 Type help, copyright, credits or license for more information. from mycalc import convertPath Traceback (most

Re: [Tutor] Using .po translation file

2011-08-03 Thread Steven D'Aprano
Григор Колев wrote: Hi. Some one help me. Haw can I use .po translation file for my program. This is not a standard part of Python. Is this a django thing? You should ask on a django forum. -- Steven ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Puzzled again

2011-08-03 Thread Steven D'Aprano
Richard D. Moores wrote: I wrote before that I had pasted the function (convertPath()) from my initial post into mycalc.py because I had accidentally deleted it from mycalc.py. And that there was no problem importing it from mycalc. Well, I was mistaken (for a reason too tedious to go into).

Re: [Tutor] commandline unable to read numbers? (Steven D'Aprano)

2011-08-07 Thread Steven D'Aprano
Robert Sjoblom wrote: [...] Have you tried just pressing enter without entering anything? Yes, and it goes back to We need to know who you are, so please choose either: The setup.py in question is the distutils.core one (from distutils.core import setup). It sounds like Peter Otten has the

Re: [Tutor] Missing in web.py and nosetests

2011-08-08 Thread Steven D'Aprano
李龑 wrote: Hi all, I'm new in python and is learning about testing my little web.py app with nosetests. When the app is running in the web browser, it's ok. And the terminal returns something like 127.0.0.1:51936 - - [08/Aug/2011 23:00:37] HTTP/1.1 GET /hello - 200 OK But when I'm trying to

Re: [Tutor] Missing in web.py and nosetests

2011-08-08 Thread Steven D'Aprano
李龑 wrote: Thanks Steven. Sorry for trying to discuss nose or templates here :( No need to be sorry, it isn't forbidden, but you may have more success asking help elsewhere. Do you actually have a template called hello_form? If not, then my *guess* is that this is an *error* (even though

Re: [Tutor] precision?

2011-08-09 Thread Steven D'Aprano
Shwinn Ricci wrote: When comparing a given value with a database of values, but allowing for freedom due to variation at say, the thousandth digit, how does one generalize the precision to this degree? I don't want to truncate, so is there a round() function that takes into account what decimal

  1   2   3   4   5   6   7   8   9   10   >