Re: [Tutor] Ongoing trouble with Turtle's end_fill() - caused by abug in turtle.py
Dick Moores schrieb: Here better tracer() should come in! 'Deprecated in version 2.6'?? And the doc gives nary a clue how to use it. http://docs.python.org/dev/library/turtle.html#turtle.tracer tracer is only deprecated as a Turtle-method, because it doesn't concern single turtles but all the turtles on the screen. It will stay as Screen-method and of course also as function. (As a turtle-method it's only there because of compatibility with the old turtle module.) Gregor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Ongoing trouble with Turtle's end_fill() - Important note!
P.S.: If you are interested, you can download a series of sample programs covering a broad range from very easy to fairly advanced, which intend to show some features and capabilities of the new turtle module from here: http://svn.python.org/view/python/trunk/Demo/turtle/ These will be included in the source distribution - but not in the Windows installer. IMPORTANT NOTE! In order to have the examples working correctly you have to have turtle.cfg in the directory where the example scripts are (or in that with turtle.py). An easy way to have a look at all the examplescripts is using turtleDemo.py Gregor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Firstrade Authentication: Form Management
Kent hi I am still unable to enter data into textbox and getting back server reply. The main problem is that I do not understand which fileds / header to observer using Firefox Fireburg. Atteched you can see headers I went through. With red font I marked differences among stages. In nider of the headers I didn't find fieldds you included in your workable login code. Questions: 1.) Could you send print screens of what you are using in Firefox Fireburg 2.) In case I am using the currect headres, I would appreciate you mark on the attached document with pink font important fields to be included in the code in order to be able to get data from server. 3.) The most usefull (the quickest to understand and re-use) would be if you coud make workable code to get server reply for XSNX stock ticker(on screen top left corner: field Symbol - enter XSNX). Once I would see this I would be able to adjust other searches by myselves. This would be realy usefull knowledge. At the moment I am able to do web control with iMacro only. I would like to switch to Python! Login - fake account https://investor.firstrade.com/firstrade/login.do User: janezfedero Pass: kmet555 Side where stock to enter stock Symbole: https://investor.firstrade.com/firstrade/mainmenu.do Workable login code: (The code open main side on which stock symbol can be entered. The question is how to what fields form header to be used and how to put this in the code. Headers can be seen in the attached word file) import urllib2 import urllib opener = urllib2.build_opener(urllib2.HTTPCookieProcessor()) urllib2.install_opener(opener) f = opener.open('https://investor.firstrade.com/firstrade/login.do') data = f.read() f.close() params = dict(username='janezfedero', password='kmet555', destination='') params['login.x'] = 'Log+In' params = urllib.urlencode(params) f = opener.open('https://investor.firstrade.com/firstrade/login.do', params) data = f.read() f.close() # print(data) f = opener.open('https://investor.firstrade.com/firstrade/stockorder.do', params) data = f.read() f.close() print(data) On Mon, 4 Aug 2008 at 16:08:33, Kent Johnson wrote: On Mon, Aug 4, 2008 at 8:05 AM, Federo [EMAIL PROTECTED] wrote: Kent THANKS! It works great also on real account .. Two important Sub-QUESTIONS: 1.) Look attached word file. It describes form fields I would like to fill in and read server resoult.. You just have to mimic what the browser does. Use a Firefox plugin that shows you what is being submitted; TamperData is one. Then set the same fields in your code. 2.) Could you do the same login logic also with MECHANIZE plagin. There are some very usefull function in this plagin I might use. However I have No, I'm not familiar with mechanize. Kent http://www.email.si/ FormManagement_Note.rtf Description: FormManagement_Note.rtf ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] date formatter
On Fri, Aug 8, 2008 at 1:34 AM, Christopher Spears [EMAIL PROTECTED] wrote: Ok, here is the working version of my program. Thanks for all of the advice: #!/usr/bin/python import time class date_format(object): This is a bit of a misnomer, you aren't formatting the date, you are parsing it. def __init__(self, month, day, year): month_dict = {(jan,january) : 1, (feb,february) :2, (mar, march) : 3, (apr, april) : 4, (may,) : 5, (jun, june) : 6, (jul, july) : 7, (aug, august) : 8, (sep, september) : 9, (oct, october): 10, (nov, november): 11, (dec, december): 12 } try: month_number = int(month) except ValueError: for eachKey in month_dict.keys(): if month.lower() in eachKey: month_number = month_dict[eachKey] break month_dict might as well be a list, you aren't using the dict-ness of it at all. months = [ ((jan,january) , 1), ... ] try: month_number = int(month) except ValueError: for names, number in months(): if month.lower() in names: month_number = number break else: month_number = 0 You might be interested in this project: http://code-bear.com/code/parsedatetime/ Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Firstrade Authentication: Form Management
On Fri, Aug 8, 2008 at 5:12 AM, Federo [EMAIL PROTECTED] wrote: Kent hi I am still unable to enter data into textbox and getting back server reply. The main problem is that I do not understand which fileds / header to observer using Firefox Fireburg. Atteched you can see headers I went through. With red font I marked differences among stages. In nider of the headers I didn't find fieldds you included in your workable login code. Hi Federo, This isn't really a Python question anymore, it is a matter of figuring out what the server requires. You have to look at the form data as well as the headers. TamperData is one Firefox pluging that can do that, I'm sure there are others as well. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Confused about import Numeric vs import numpy for Arrays
Hi Everyone, I would like to create a two-dimensional array but am confused as to how to go about it. I've read about Numeric Python and Numpy. Are they one and the same? Also, how do I install them? I am working on a Windows machine. I've been getting the following error messages: import Numeric Traceback (most recent call last): File pyshell#3, line 1, in module import Numeric ImportError: No module named Numeric from Numeric import * Traceback (most recent call last): File pyshell#4, line 1, in module from Numeric import * ImportError: No module named Numeric I then downloaded and installed release 1.1.1 of the Numpy package from this site: http://sourceforge.net/project/showfiles.php?group_id=1369package_id=175103 After restarting the shell, I still get the same errors above (though I do have this directory now: C:\Python25\Lib\site-packages\numpy). Anyone know how to correctly install and use this package? Thanks in advance. Samir ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Confused about import Numeric vs import numpy for Arrays
On Fri, Aug 8, 2008 at 11:56 AM, S Python [EMAIL PROTECTED] wrote: Hi Everyone, I would like to create a two-dimensional array but am confused as to how to go about it. I've read about Numeric Python and Numpy. Are they one and the same? No, they are not the same. Numeric is older; NumArray is another older package. You should use Numpy if you can. http://numpy.scipy.org/#older_array I then downloaded and installed release 1.1.1 of the Numpy package from this site: http://sourceforge.net/project/showfiles.php?group_id=1369package_id=175103 After restarting the shell, I still get the same errors above (though I do have this directory now: C:\Python25\Lib\site-packages\numpy). Anyone know how to correctly install and use this package? Now you should be able to import numpy. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Confused about import Numeric vs import numpy for Arrays
No, they are not the same. Numeric is older; NumArray is another older package. You should use Numpy if you can. http://numpy.scipy.org/#older_array snip Now you should be able to import numpy. Kent Thanks, Kent. I ended up using: from numpy import * I wasn't sure what the difference was between this and import numpy Thanks! Samir ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Confused about import Numeric vs import numpy for Arrays
On Fri, Aug 8, 2008 at 9:29 AM, S Python [EMAIL PROTECTED] wrote: No, they are not the same. Numeric is older; NumArray is another older package. You should use Numpy if you can. http://numpy.scipy.org/#older_array snip Now you should be able to import numpy. Kent Thanks, Kent. I ended up using: from numpy import * I wasn't sure what the difference was between this and import numpy Thanks! Samir In general from module import * is a very bad idea. import module imports a module into its own namespace (e.g., to access its functionality you would have to do module.foo() and module.bar() The form that you chose to use imports all of a module's contents into the current namespace. This means you can call foo() and bar() directly, but it also means that if you have coded a foo() and a bar() you will not have access to the functions in the module you just imported. -- Stand Fast, tjg. [Timothy Grant] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] issue with the Backslash on IDLE 1.2.2
hi, I would like to make some regular expression, unfortunately I can't because the backslash doesn't work at all on IDLE 1.2.2 did someone already try this on a MacBook? The combination to do the backslash works properly (\ as you can see) but not in IDLE Doesn't someone notice already these ? thanks for you feedback Marc ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Ongoing trouble with Turtle's end_fill() - caused by abug in turtle.py
Hi Dick, just to show you a bit of the versatility of the new turtle module I've prepared to tiny rectangle-generator program examples. They intentionally use different programming styles and also turtle graphics techniques different from the ones you used to accomplish something similar to what you did, of course in a very simplified way and without your eleborated user interface and colormanagement. --- Version 1: procedural, using stamp() --- from turtle import * from random import random, randint from time import sleep MAXLEN = 30 MAXWID = 25 def randomcolor(): return random(), random(), random() reset() title(Python turtle graphics: random rectangle generator) hideturtle() resizemode(user) shape(square) for cycle in range(randint(3, 5)): bgcolor(randomcolor()) for rect in range(randint(5,10)): shapesize(3 + random()*MAXLEN, 3 + random()*MAXWID, randint(3, 10)) color(randomcolor(), randomcolor()) stamp() sleep(0.5) sleep(1) clearstamps() --- Version 2: object oriented, uses a list of turtles, which change their properties (size, color, visibility) --- from turtle import Screen, Turtle from random import random, randint from time import sleep MAXLEN = 30 MAXWID = 25 def randomcolor(): return random(), random(), random() class RectGenerator(object): def __init__(self): self.s = s = Screen() s.reset() s.title(Python turtle graphics: random rectangle generator) self.rectturtles = [] for n in range(10): t = Turtle(visible=False) t.hideturtle() t.resizemode(user) t.shape(square) self.rectturtles.append(t) def run(self): for cycle in range(randint(3, 5)): self.s.bgcolor(randomcolor()) n = randint(5,10) for index in range(n): t = self.rectturtles[index] t.shapesize(3 + random()*MAXLEN, 3 + random()*MAXWID, randint(3, 10)) t.color(randomcolor(), randomcolor()) t.showturtle() sleep(0.5) sleep(1) for t in self.s.turtles(): t.hideturtle() if __name__ == __main__: rg = RectGenerator() rg.run() Hope you like it Gregor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Confused about import Numeric vs import numpy for Arrays
In general from module import * is a very bad idea. import module imports a module into its own namespace (e.g., to access its functionality you would have to do module.foo() and module.bar() The form that you chose to use imports all of a module's contents into the current namespace. This means you can call foo() and bar() directly, but it also means that if you have coded a foo() and a bar() you will not have access to the functions in the module you just imported. Timothy, Thanks for the clarification. I had always wondered what the difference was. Samir ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] issue with the Backslash on IDLE 1.2.2
Marc Rambert wrote: hi, I would like to make some regular expression, unfortunately I can't because the backslash doesn't work Please explain doesn't work. I interpret that as I press the \ key and nothing shows up in the active window. -- Bob Gailer Chapel Hill NC 919-636-4239 When we take the time to be aware of our feelings and needs we have more satisfying interatctions with others. Nonviolent Communication provides tools for this awareness. As a coach and trainer I can assist you in learning this process. What is YOUR biggest relationship challenge? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] I need a Python mentor
Hello everybody, i`m new to this list. I was programming in PHP before, of recent I started learning python. I need someone who can be giving me some assignment based on the chapter I read in the book, and the person will sometime review my code and tell me if it`s well structured. Thanks- ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] I need a Python mentor
Actually the way this list works is there is no one person who will do this. However if you pose a specific question I'm sure you will get several helpful people will respond. Like this. What book did you read and what topics did it cover? From there someone perhaps even myself will be able to make up something nice for you to program. Then when you have problems with the program come back and ask questions. Since you already programmed in PHP I don't think you'll have too much trouble picking up python. On Fri, Aug 8, 2008 at 5:22 PM, A. Joseph [EMAIL PROTECTED] wrote: Hello everybody, i`m new to this list. I was programming in PHP before, of recent I started learning python. I need someone who can be giving me some assignment based on the chapter I read in the book, and the person will sometime review my code and tell me if it`s well structured. Thanks- ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] I need a Python mentor
Hi, I'm a beginner in python, so I can't be a mentor, but here are some links that may help: http://uselesspython.com/ Python Wiki at: http://wiki.python.org/ Also google Think Python. It is a great resource. Nick On Fri, Aug 8, 2008 at 4:22 PM, A. Joseph [EMAIL PROTECTED] wrote: Hello everybody, i`m new to this list. I was programming in PHP before, of recent I started learning python. I need someone who can be giving me some assignment based on the chapter I read in the book, and the person will sometime review my code and tell me if it`s well structured. Thanks- ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Art: bellsoffreedom.cgsociety.org/gallery/ Blog: cognitivealchemy.blogspot.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] I need a Python mentor
A. Joseph [EMAIL PROTECTED] wrote Hello everybody, i`m new to this list. I was programming in PHP before, of recent I started learning python. I need someone who can be giving me some assignment based on the chapter I read in the book, and the person will sometime review my code and tell me if it`s well structured. While some individual may volunteer its unlikely. The way the list works you pose questions and anyone on the list who knows (or thinks they do) the answer will reply. If you have code either post it in a mail(if short) or post a link to pastebin or some similar site. Hopefully some folks will have the time and intreest to review it. If you have studied a tyopic and want ideas on how to put it into practice just ask. Be as specific as possible. State where you are studying - tutorial, book, video etc. If you are getting errors post a short program that demonstrates the error plus all of the error text. You should get a reply pretty quickly. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Confused about import Numeric vs import numpy forArrays
S Python [EMAIL PROTECTED] wrote Thanks for the clarification. I had always wondered what the difference was. A useful tip is that if you have a long module name you can also use import module as shortname eg import numpy as n and then access numpy.foo() as n.foo() Sacves a lot of typing for a slight loss of clarity in maintenance - you have to remember which module the short names refer to! I tend to use full names in real code and use the abbreviated form when using the prompt. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Confused about import Numeric vs import numpy for Arrays
On Fri, Aug 8, 2008 at 1:25 PM, Timothy Grant [EMAIL PROTECTED] wrote: In general from module import * is a very bad idea. import module imports a module into its own namespace (e.g., to access its functionality you would have to do module.foo() and module.bar() The form that you chose to use imports all of a module's contents into the current namespace. This means you can call foo() and bar() directly, but it also means that if you have coded a foo() and a bar() you will not have access to the functions in the module you just imported. Another reason not to use from xx import * is that it can make it very difficult to discover where a name is defined. If you have several from xx import * lines and then later you use a function foo() there is no easy way to tell which module foo came from. An alternative is to list just the names you want to import: from xx import foo Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Confused about import Numeric vs import numpy forArrays
A useful tip is that if you have a long module name you can also use import module as shortname eg import numpy as n and then access numpy.foo() as n.foo() Sacves a lot of typing for a slight loss of clarity in maintenance - you have to remember which module the short names refer to! I tend to use full names in real code and use the abbreviated form when using the prompt. Alan - Great suggestion! As I'm reading through the numpy documentation, there are a lot of great functions that I'd like to learn to use so your advice definitely helps. I was getting tired of constantly having to type numpy.array or numpy.ones all the time. Thanks again. Samir ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Confused about import Numeric vs import numpy for Arrays
Another reason not to use from xx import * is that it can make it very difficult to discover where a name is defined. If you have several from xx import * lines and then later you use a function foo() there is no easy way to tell which module foo came from. An alternative is to list just the names you want to import: from xx import foo Kent Kent - Another great point. Thanks for contributing to the list. Samir ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] To Tutor subscribers: should I send detailed questions about the Python 2.6b2's Turtle to the list?
The thread I started continues, and now concerns mainly the new Turtle module in Python 2.6b2. I am very interested in this, but I'm wondering is there are other 'kids out there who are. Should I ask our resident expert, Gregor Lingl directly, or through the list? Opinions, please? Dick Moores, who is in his 2nd kidhood. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] To Tutor subscribers: should I send detailed questionsabout the Python 2.6b2's Turtle to the list?
Dick Moores [EMAIL PROTECTED] wrote The thread I started continues, and now concerns mainly the new Turtle module in Python 2.6b2. I am very interested in this, but I'm wondering is there are other 'kids out there who are. Should I ask our resident expert, Gregor Lingl directly, or through the list? Opinions, please? Turtle is often used by beginners. Understanding the new modules foibles early seems a reasonable thread to pursue on this list. Lets just try to keep it in a single thread so that those who are not interested can filter it out and those searching in the future can find the full discourse. My view FWIW, Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor