Pujo Aji | 1 Jan 2006 12:34
Picon

Numeric RandomArray seed problem.

Hello,

I tried calling RandomArray.seed()
by calling RandomArray.get_seed() I get the seed number (x,y).
My problem is that x is always 113611 any advice?

Thanks
pujo

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
Kent Johnson | 1 Jan 2006 13:54
Gravatar

Re: Numeric RandomArray seed problem.

Pujo Aji wrote:
> Hello,
> 
> I tried calling RandomArray.seed()
> by calling RandomArray.get_seed() I get the seed number (x,y).
> My problem is that x is always 113611 any advice?

Take a look at the source for RandomArray.seed(). It more-or-less splits 
the decimal representation of the current time in half, using the high 
digits for x and the low digits for y. So x will change slowly, every 
few hours.

Kent

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Pujo Aji | 1 Jan 2006 14:33
Picon

Re: Numeric RandomArray seed problem.

Thank you Kent.

pujo

On 1/1/06, Kent Johnson <kent37 <at> tds.net> wrote:
Pujo Aji wrote:
> Hello,
>
> I tried calling RandomArray.seed()
> by calling RandomArray.get_seed() I get the seed number (x,y).
> My problem is that x is always 113611 any advice?

Take a look at the source for RandomArray.seed(). It more-or-less splits
the decimal representation of the current time in half, using the high
digits for x and the low digits for y. So x will change slowly, every
few hours.

Kent

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
Don Jennings | 1 Jan 2006 20:11
Picon
Favicon

Re: [OT] Python Tutor like java mailing list

I suggest the beginners' forum at javaranch.com (they even give away 
free books on occasion : >)

http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=forum&f=33

Take care,
Don

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Eli Zabielski | 2 Jan 2006 08:07
Picon

Python to C?

Is there any way to convert a program in .py to .c? other then remakeing the program?

Eli Zabielski

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
John Joseph | 2 Jan 2006 09:48
Picon
Favicon
Gravatar

TypeError: object doesn't support item assignment [ Trying to learn how to enter value in array ]


Hi All
   I am trying to write a program in  which I enter
the no of students and then for the students I enter
the marks and later on Display the marks 
The script which I wrote is  given below , when I run
the program I get error 
“TypeError: object doesn't support item assignment “ ,
my aim in doing  this program is to learn how to enter
values in a array , please advice  how can I avoid
this error
           Guidance requested 
                   Thanks 
                     Joseph 

##################################################################
# This program is to learn how u enter entry to the
array
# And how u print it ,

print " \nFirst Enter the No of Students ... "
print "\n Then No of marks "

# defining empty array a
a = ()
# defining i
i = 0

# n is the No of  students which I have to enter the
marks
n = int(raw_input("Enter the no: of students :  \n"))

# m is the Marks of the students which I have to enter
while i < n:
        m = int(raw_input("Enter the Marks for the
students :  \n"))
        a[i] = m
        print "Marks are ", m
        i = i+1

#print "Array Marks ", a[i]

		
___________________________________________________________ 
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Brian van den Broek | 2 Jan 2006 10:55
Picon
Picon
Favicon

Re: TypeError: object doesn't support item assignment [ Trying to learn how to enter value in array ]

John Joseph said unto the world upon 02/01/06 02:48 AM:
 > Hi All
 >    I am trying to write a program in  which I enter
 > the no of students and then for the students I enter
 > the marks and later on Display the marks
 > The script which I wrote is  given below , when I run
 > the program I get error
 > “TypeError: object doesn't support item assignment “ ,
 > my aim in doing  this program is to learn how to enter
 > values in a array , please advice  how can I avoid
 > this error
 >            Guidance requested
 >                    Thanks
 >                      Joseph
 >
 > ##################################################################
 > # This program is to learn how u enter entry to the
 > array
 > # And how u print it ,
 >
 >
 > print " \nFirst Enter the No of Students ... "
 > print "\n Then No of marks "
 >
 > # defining empty array a
 > a = ()
 > # defining i
 > i = 0
 >
 > # n is the No of  students which I have to enter the
 > marks
 > n = int(raw_input("Enter the no: of students :  \n"))
 >
 >
 > # m is the Marks of the students which I have to enter
 > while i < n:
 >         m = int(raw_input("Enter the Marks for the
 > students :  \n"))
 >         a[i] = m
 >         print "Marks are ", m
 >         i = i+1
 >
 > #print "Array Marks ", a[i]

Hi John,

the whole traceback is helpful, as it (tries to) show the line that 
made Python choke:

Traceback (most recent call last):
   File "/home/tempos/foo.py", line 16, in -toplevel-
     a[i] = m
TypeError: object does not support item assignment

See how that shows us that it is the a[i] = m that is the problem?

See if this helps work it out:

 >>> a_tuple = ()
 >>> a_tuple[0] = "Won't work, as tuples are immutable"

Traceback (most recent call last):
   File "<pyshell#7>", line 1, in -toplevel-
     a_tuple[0] = "Won't work, as tuples are immutable"
TypeError: object does not support item assignment
 >>> a_list = []
 >>> a_list[0] = "Won't work, different reason"

Traceback (most recent call last):
   File "<pyshell#9>", line 1, in -toplevel-
     a_list[0] = "Won't work, different reason"
IndexError: list assignment index out of range
 >>> a_preloaded_list = [None]
 >>> a_preloaded_list[0] = "Will work, but not the best way generally"
 >>> a_preloaded_list
['Will work, but not the best way generally']
 >>>

It doesn't seem that you are aiming to correlate marks with students 
yet, but just want a list of marks. In that case:

 >>> marks = []  # 'a' is not a helpful name :-)
 >>> mark = raw_input("What mark?")
What mark?17
 >>> marks.append(mark)
 >>> mark = raw_input("What mark?")
What mark?42
 >>> marks.append(mark)
 >>> marks
['17', '42']
 >>>

HTH,

Brian vdB
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
Alan Gauld | 2 Jan 2006 15:38
Picon

Re: Python to C?

>Is there any way to convert a program in .py to .c? other then remakeing
> the program?

Thee are a couuple of projects designed to make Python run faster which
try to convert Python to something like C and compile it but its not a 
general
solution and the C produced isn't in any way readable.

It would be possible to write a general convertor but its value is 
debateable
since the Python style is very different to the C style. For example C is 
heavily
geared to the use of pointers and pointer arithmetic, whereas Python doesn't
have any such concept and works at a higher level.

To translate Python into C would, I suspect,  result in very inefficient C.
It would be much better to use Puython as executable Pseudo code
and then rewrite it in 'good' C.

Alan G

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Noah Bedford | 2 Jan 2006 19:29
X-Face
Picon

Re: new to linux and I cannot find some python things

On Fri, 30 Dec 2005 10:22:32 +1300
"Hans Dushanthakumar" <Hans.Dushanthakumar <at> navman.com> wrote:

>Anothet linux noobie here :)
>How do I uninstall python? I use the SimplyMepis flavor of linux.

If you installed using apt, apt-get remove python-2.3.
I would reccomend just apt-get update'ing, and then apt-get install
python-2.4 should do it. (but it has been a while since I switched to 
ubuntu from mepis, things could have changed.)

--

-- 
-\n
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

John Corry | 2 Jan 2006 15:55

Printing error on Win 98SE

Hi + Happy New Year,

With help from several people from the mailing list I have been able to
print out text files on my windows XP machine.  I have tried using the same
program on my windows 98SE machine and I get the following error:

PythonWin 2.4.2 (#67, Oct 30 2005, 16:11:18) [MSC v.1310 32 bit (Intel)] on
win32.
Portions Copyright 1994-2004 Mark Hammond (mhammond <at> skippinet.com.au) - see
'Help/About PythonWin' for further copyright information.
Traceback (most recent call last):
  File
"C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
line 310, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\test\Script1.py", line 12, in ?
    0
error: (31, 'ShellExecute', 'A device attached to the system is not
functioning.')
>>>

I can manually right click the text file and left click print and the file
will print to the printer.

The code that I am using is below:

import win32api
filename = "testprint.txt"
fileobj=open (filename, "w")
fileobj.write ("This is a test")
fileobj.close()
win32api.ShellExecute (
  0,
  "print",
  filename,
  None,
  ".",
  0
)

Any help would be greatly appreciated.

Thanks,

John.

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor


Gmane