Re: [Tutor] Introduction to modelling with Python

2010-03-28 Thread Modulok
Could you further define 'modeling' in context? Are you referring to using python in the context of 3D modeling, i.e. computer aided design? If that be the case, python serves as an embedded language for many 3D computer graphics programs. Everything from Maya to Houdini use it as a command interf

Re: [Tutor] Prime numbers

2010-03-28 Thread Rafik Ouerchefani
On Sat, Mar 27, 2010 at 11:08 PM, yd wrote: > > Having a problem finding the first 1000 prime numbers, here is my code:- > > print(2) > n =3 > counter =1 > while counter <=1000: >   for x in range(3,int((n**0.5)),2): >     if n%x != 0: >   print(n) >   n+=1 >   counter+=1 >     else: >

Re: [Tutor] Prime numbers

2010-03-28 Thread Luke Paireepinart
On Sat, Mar 27, 2010 at 5:08 PM, yd wrote: > > Having a problem finding the first 1000 prime numbers, here is my code:- > > print(2) > n =3 > counter =1 > while counter <=1000: > for x in range(3,int((n**0.5)),2): > if n%x != 0: > print(n) > n+=1 > counter+=1 > else: >

Re: [Tutor] Introduction to modelling with Python

2010-03-28 Thread AG
Modulok wrote: Could you further define 'modeling' in context? Are you referring to using python in the context of 3D modeling, i.e. computer aided design? If that be the case, python serves as an embedded language for many 3D computer graphics programs. Everything from Maya to Houdini use it as

[Tutor] inter-module global variable

2010-03-28 Thread spir ☣
Hello, I have a main module importing other modules and defining a top-level variable, call it 'w' [1]. I naively thought that the code from an imported module, when called from main, would know about w, but I have name errors. The initial trial looks as follows (this is just a sketch, the orig

Re: [Tutor] inter-module global variable

2010-03-28 Thread Steven D'Aprano
On Sun, 28 Mar 2010 08:31:57 pm spir ☣ wrote: > Hello, > > I have a main module importing other modules and defining a top-level > variable, call it 'w' [1]. I naively thought that the code from an > imported module, when called from main, would know about w, Why would it? If you write a module

Re: [Tutor] Prime numbers

2010-03-28 Thread yd
> > > > What 'problem' are you trying to solve? > In general, anytime you can use a premade solution, you are at an > advantage, > not cheating. > That's one of the marks of a truly good programmer - being able to reuse as > much code as possible. > Unless it's a homework problem and he said "don't

Re: [Tutor] inter-module global variable

2010-03-28 Thread Dave Angel
spir # wrote: Hello, I have a main module importing other modules and defining a top-level variable, call it 'w' [1]. I naively thought that the code from an imported module, when called from main, would know about w, but I have name errors. The initial trial looks as follows (this is just a

Re: [Tutor] python magazine

2010-03-28 Thread Lowell Tackett
>From the virtual desk of Lowell Tackett --- On Sat, 3/27/10, Dave Angel wrote: > From: Dave Angel > Subject: Re: [Tutor] python magazine > To: "Lowell Tackett" > Cc: "Benno Lang" , tutor@python.org > Date: Saturday, March 27, 2010, 6:12 AM > > > Lowell Tackett wrote: > > >From the virt

Re: [Tutor] Introduction to modelling with Python

2010-03-28 Thread spir ☣
On Sun, 28 Mar 2010 10:26:43 +0100 AG wrote: > Modulok wrote: > > Could you further define 'modeling' in context? [...] > The modelling I was referring to is not about 3-D design, but about > scenario modelling. For example, to understand the impacts of climate > change on particular bodies o

Re: [Tutor] Prime numbers

2010-03-28 Thread Lie Ryan
On 03/28/2010 09:57 PM, yd wrote: > It's not homework i just want to be able to convert my algorithm into > good code, and the only way to do that is by actually writing it. I'm > just writing it to learn how it's done. In most cases, when: 1) the code is effective (i.e. it always gives correct an

Re: [Tutor] python magazine

2010-03-28 Thread Dave Angel
Lowell Tackett wrote: >From the virtual desk of Lowell Tackett --- On Sat, 3/27/10, Dave Angel wrote: From: Dave Angel Subject: Re: [Tutor] python magazine To: "Lowell Tackett" Cc: "Benno Lang" , tutor@python.org Date: Saturday, March 27, 2010, 6:12 AM Lowell Tackett wrote: >F

Re: [Tutor] inter-module global variable

2010-03-28 Thread spir ☣
On Sun, 28 Mar 2010 21:50:46 +1100 Steven D'Aprano wrote: > On Sun, 28 Mar 2010 08:31:57 pm spir ☣ wrote: > > Hello, > > > > I have a main module importing other modules and defining a top-level > > variable, call it 'w' [1]. I naively thought that the code from an > > imported module, when call

Re: [Tutor] Introduction to modelling with Python

2010-03-28 Thread Eike Welk
On Saturday March 27 2010 16:21:26 AG wrote: > I apologise in advance for the vagueness of this query, but I am looking > for a decent modern introduction to modelling using Python. > Specifically, I want something that is a good introduction (i.e. doesn't > expect one to already be a maths/ statis

[Tutor] automatic output file naming scheme

2010-03-28 Thread kevin parks
okay. I got the subprocess bit to work and i have os walk doing its walk. But now for something i did not think about until i started to think about how to fit these two bits to work together. os walk is going to traverse my dirs from some given starting point and process files that it finds th

Re: [Tutor] "IOError: [Errno 32] Broken pipe" when running python with cron (alternatives?)

2010-03-28 Thread Emile van Sebille
On 3/27/2010 5:45 AM Karjer Jdfjdf said... I have made an extensive script that runs fine when started from the command line or IDLE. When I try to run it with cron it keeps giving errors: Often when I have trouble running scripts from cron it's because something in the environment is differ

Re: [Tutor] automatic output file naming scheme

2010-03-28 Thread Emile van Sebille
On 3/28/2010 8:44 AM kevin parks said... okay. I got the subprocess bit to work and i have os walk doing its walk. But now for something i did not think about until i started to think about how to fit these two bits to work together. os walk is going to traverse my dirs from some given startin

Re: [Tutor] automatic output file naming scheme

2010-03-28 Thread Emile van Sebille
On 3/28/2010 8:44 AM kevin parks said... okay. I got the subprocess bit to work and i have os walk doing its walk. But now for something i did not think about until i started to think about how to fit these two bits to work together. os walk is going to traverse my dirs from some given startin

Re: [Tutor] First extension

2010-03-28 Thread Emile van Sebille
On 3/26/2010 7:03 PM James Reynolds said... Hello All, I'm trying to write my first extension module, and I am getting the following error in my command prompt and I was hoping you all could help me. Hi James, You'll probably get further asking on the setuptools support list. Checking http:/

[Tutor] ask

2010-03-28 Thread Shurui Liu (Aaron Liu)
Since English is not my native language, so I got confused by some requirement of my assignment. I already done, just want to make sure what I did is what the assignment required, thank you! BTW, I don't know how to do this: If I want to fix some wrong words in a text file, how can I print out the

Re: [Tutor] ask

2010-03-28 Thread Shurui Liu (Aaron Liu)
You know what, I just don't understand this line: the name of the file containing the translated output is storyAmer.txt and it is to located. I don't know what kind of translated output he need. I guess: 1. the name of the file containing the translated output is * storyAmer.txt* and it i

Re: [Tutor] Introduction to modelling with Python

2010-03-28 Thread AG
Eike Welk wrote: On Saturday March 27 2010 16:21:26 AG wrote: I apologise in advance for the vagueness of this query, but I am looking for a decent modern introduction to modelling using Python. Specifically, I want something that is a good introduction (i.e. doesn't expect one to already be

Re: [Tutor] ask

2010-03-28 Thread Emile van Sebille
On 3/28/2010 10:28 AM Shurui Liu (Aaron Liu) said... > You know what, I just don't understand this line: > the name of the file containing the translated output is storyAmer.txt > and it is to located. It sounds to me like we wants you to read in the source(british) version, swap in the american s

Re: [Tutor] ask

2010-03-28 Thread Shurui Liu (Aaron Liu)
I came out with a transigent answer: save the right text file*(storyAmer.txt *) at the right place /cset1100py/assign19/ storyAmer.txt. Then I just add a command after the command which picked out wrong words. I wanna add text_file = open("storyAmer.txt", "r") But I don't know how to add its path

Re: [Tutor] inter-module global variable

2010-03-28 Thread bob gailer
On 3/28/2010 5:31 AM, spir ☣ wrote: Hello, I have a main module importing other modules and defining a top-level variable, call it 'w' [1]. I naively thought that the code from an imported module, when called from main, would know about w, but I have name errors. The initial trial looks as fo

Re: [Tutor] Introduction to modelling with Python

2010-03-28 Thread Eike Welk
On Sunday March 28 2010 19:37:41 AG wrote: > Now that's looking very much along the lines of what I had in mind > Eike. Very pricey ... might have to sit on that one for a while and > scout around for a used copy. I can certainly use the on-line resource > for as many pages as it allows one to ac

Re: [Tutor] Introduction to modelling with Python

2010-03-28 Thread AG
Eike Welk wrote: On Sunday March 28 2010 19:37:41 AG wrote: Now that's looking very much along the lines of what I had in mind Eike. Very pricey ... might have to sit on that one for a while and scout around for a used copy. I can certainly use the on-line resource for as many pages as it a

[Tutor] how to change some words in a text file

2010-03-28 Thread Shurui Liu (Aaron Liu)
Here's the thing, I wanna change some wrong words from a text file like this: "I am a studaet." -> "I am a student." I have tried to use this command: str = "I am a studaet." newstr = str[0:8] + "ent" print newstr But the system said TypeError: 'type' object is unsubscriptable What's wrong

Re: [Tutor] how to change some words in a text file

2010-03-28 Thread Emile van Sebille
On 3/28/2010 2:23 PM Shurui Liu (Aaron Liu) said... Here's the thing, I wanna change some wrong words from a text file like this: "I am a studaet." -> "I am a student." I have tried to use this command: str = "I am a studaet." newstr = str[0:8] + "ent" print newstr But the system said Ty

Re: [Tutor] how to change some words in a text file

2010-03-28 Thread Shashwat Anand
>>> s = "I am a studaet." >>> new_s = s[0:8] + 'ent' >>> print new_s I am a sent You are using str as a variable, str is used to convert anything into string >>> a = 0 >>> b = str(a) >>> type(b) On Mon, Mar 29, 2010 at 2:53 AM, Shurui Liu (Aaron Liu) wrote: > Here's the thing, I wanna change

Re: [Tutor] Introduction to modelling with Python

2010-03-28 Thread Eike Welk
Also bookmark this page, it will be very useful once you have a little knowledge about Numpy: http://www.scipy.org/Numpy_Example_List_With_Doc This is the page that I use most often. Eike. ___ Tutor maillist - Tutor@python.org To unsubscribe or cha

Re: [Tutor] how to change some words in a text file

2010-03-28 Thread Shurui Liu (Aaron Liu)
Tell me how to do what i want, please. 2010/3/28 Shashwat Anand : s = "I am a studaet." new_s = s[0:8] + 'ent' print new_s > I am a sent > > You are using str as a variable, str is used to convert anything into string > a  = 0 b = str(a) type(b) > > > > On Mon, Mar 2

[Tutor] bind line-oriented device output?

2010-03-28 Thread Tom Roche
I'd like to learn to pythonically redirect the output from a line-oriented character device to a particular file or process, regardless of focus, on a generic graphical OS. But I don't want to redirect stdin entirely. Here's the usecase: My school has a seminar for which we record attendance by s

Re: [Tutor] how to change some words in a text file

2010-03-28 Thread Walter Prins
On 28 March 2010 23:37, Shurui Liu (Aaron Liu) wrote: > Tell me how to do what i want, please. > Both me and someone else have already told you how to replace a substring in a string with something else in your earlier question/posting/thread. If you've not understood what was written there, th

[Tutor] commands

2010-03-28 Thread Shurui Liu (Aaron Liu)
# Translate wrong British words #Create an empty file print "\nReading characters from the file." raw_input("Press enter then we can move on:") text_file = open("storyBrit.txt", "r+") whole_thing = text_file.read() print whole_thing raw_input("Press enter then we can move on:") print "\nWe are gon

Re: [Tutor] inter-module global variable

2010-03-28 Thread Dave Angel
spir # wrote: On Sun, 28 Mar 2010 21:50:46 +1100 Steven D'Aprano wrote: On Sun, 28 Mar 2010 08:31:57 pm spir ☣ wrote: I'm going to assume you really want a single global value, and that you won't regret that assumption later. We talked at length about how to access that global from

Re: [Tutor] commands

2010-03-28 Thread Dave Angel
Shurui Liu (Aaron Liu) wrote: # Translate wrong British words #Create an empty file print "\nReading characters from the file." raw_input("Press enter then we can move on:") text_file = open("storyBrit.txt", "r+") whole_thing = text_file.read() print whole_thing raw_input("Press enter then we ca