Re: First Tkinter script: requesting comments

2010-05-23 Thread Francesco Bochicchio
On 21 Mag, 23:51, Bart Kastermans  wrote:
> I wrote a first script using Tkinter.  As I am new to its
> use, I am only just feeling my way around.  I would very
> much like comments on the design of the script (and in fact
> any other comments on my code would also be very welcome).
>
> I have it posted (with syntax coloring) at:
>
> http://kasterma.wordpress.com/2010/05/21/first-experiments-with-tkinter/
>
> But will also include it here for convenience.
>
> Thanks for any help,
>
> Best,
> Bart
>
> ***
>
> #!/usr/bin/env python
> #
> # Getting a list of students and grades displayed so that grades can
> # be updated, and we poll these changes (so that in the future we can
> # act on it).
> #
> # Bart Kastermans,www.bartk.nl
>
> """
> Design of the window
>
>       +-+
>       |  root                                                       |
>       |  +--+   |
>       |  | title_frame                                          |   |
>       |  |  +--+                    |   |
>       |  |  | Label(title)                 |                    |   |
>       |  |  |                              |                    |   |
>       |  |  +--+                    |   |
>       |  +--+   |
>       |  +--+   |
>       |  | exam_grades_frames                                   |   |
>       |  |  +-+ |   |
>       |  |  | Frame(ex)                                       | |   |
>       |  |  | ++  +-+ | |   |
>       |  |  | | Entry(name)        |  | Entry(grade)        | | |   |
>       |  |  | |                    |  |                     | | |   |
>       |  |  | ++  +-+ | |   |
>       |  |  +-+ |   |
>       |  |                                                      |   |
>       |  +--+   |
>       |                                                             |
>       |                 +-+                     |
>       |                 | quit_button         |                     |
>       |                 |                     |                     |
>       |                 +-+                     |
>       +-+
>
> """
>
> from Tkinter import *
>
> # global info for this specific example
>
> # four students
> no_stud = 4
> exam_grades = [1,2,3,4]
> names = ["Ben", "Jim", "James", "Mel"]
> # upper bound for name length
> max_name_len = max (map (len, names))
>
> # set up root window
> root = Tk()
> root.geometry ("400x400")
>
> exam_grades_string = map (lambda x: StringVar (root,str (x)), exam_grades)
>
> names_string = map (lambda x: StringVar (root, x), names)
>
> def setup ():
>     """ setup the window with the list of students.
>
>     This is test-code to figure out what the app finally should look
>     like.
>     """
>
>     # title frame, with title Grade Correction in it
>     title_frame = Frame(root)
>     title_frame.pack (fill=X)
>
>     w = Label (title_frame, text = "Grade Correction", font = ("Helvetica", 
> 25))
>     w.pack (side=LEFT)
>
>     # from to hold the list of grades
>     exam_grades_frame = Frame (root)
>     exam_grades_frame.pack (fill=BOTH)
>
>     exam_label = Label (exam_grades_frame, text="EXAMS")
>     exam_label.pack ()
>
>     # set up the list of grades
>     for i in range (0,no_stud):
>         # a frame per student
>         ex = Frame (exam_grades_frame)
>         ex.pack ()
>         # name on the left
>         name = Entry (ex, textvariable=names_string[i], width=max_name_len+2)
>         name.config (state=DISABLED)
>         name.pack (side=LEFT)
>         # grade next to it
>         grade = Entry (ex, textvariable=exam_grades_string [i], width=4)
>         grade.pack (side=LEFT)
>
>     # button to quit the application
>     qb = Button (root)
>     qb ['text'] = "quit"
>     qb ['command'] = root.quit
>     qb.pack ()
>
> def to_int (st):
>     """ helper function to convert strings to integers.
>
>     Empty string represents 0.
>     """
>     if len (st) == 0:
>         return 0
>     else:
>         return int (st)
>
> def get_curr_grades ():
>     """ extract the grades from exam_grades_string.
>
>     exam_grades_string consists of StringVar that get updated when the
>     fields are updated in the GUI.
>     """
>     grades = []
>     for i in range (0, no_stud):
>         grades.append (exam_grades_string [i].get())
>     return grades
>
> # get the current grades
> curr_grades = map (to_int, get_curr_grades ())
>
> def poll_exams ():
>     ""

Re: where are the program that are written in python?

2010-05-23 Thread Lie Ryan
On 05/23/10 04:49, Terry Reedy wrote:
> On 5/21/2010 11:03 PM, Lie Ryan wrote:
>> On 05/22/10 04:47, Terry Reedy wrote:
>>> On 5/21/2010 6:21 AM, Deep_Feelings wrote:
 python is not a new programming language ,it has been there for the
 last  15+ years or so ? right ?

 however by having a look at this page
 http://wiki.python.org/moin/Applications
 i could not see many programs written in python (i will be interested
 more in COMMERCIAL programs written in python ). and to be honest ,i
>>>
>>> There are two kinds of 'commercial' programs.
>>> 1. The vast majority are proprietary programs kept within a company for
>>> its own use. As long as these work as intended, they are mostly
>>> invisible to the outside world.
>>> 2. Programs sold to anyone who wants them.
>>>
>>> Python trades programmer speed for execution speed. If a successful
>>> Python program is going to be run millions of times, it makes economic
>>> sense to convert time-hogging parts to (for instance) C.  In fact, this
>>> is a consideration in deciding what functions should be builtin and
>>> which stdlib modules are written or rewritten in C.
>>>
>>> Programs being sold tend to be compared to competitors on speed with
>>> perhaps more weight than they rationally should. Speed is easier to
>>> measure than, for instance, lack of bugs.
>>
>> doubting python's speed?
> 
> The is a somewhat bizarre response to me. I have been promoting Python
> for about 13 years, since I dubbed it 'executable pseudocode', which is
> to say, easy to write, read, understand, and improve. I am also a
> realist. Any fixed (C)Python program can be sped up, at least a bit, and
> possibly more, by recoding in C. At minimum, the bytecodes can be
> replaced by the C code and C-API calls that they get normally get
> translated into. Ints can be unboxed. Etcetera. This tend to freeze a
> program, which is fine when development is finished.

I'm not claiming Python is faster than C, but I'm just being a realists,
when I say that in real life 9 out of 10 writing a program in a slow
language doesn't really matter to actual program speed. I used Mercurial
as an example where the developers choose an initially irrational
decision of using a slow language (python) to beat the speed of a fast
language (C).

Of course, you can always point out the 1 case out of 10. In this cases,
python can still cope with C extension, Psyco, Numpy-and-friends,
Cython, or even dumping python and using full C all the way.

But the point still hold, that in real life, often the language's raw
speed doesn't really limit the program's speed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help (I can't think of a better title)

2010-05-23 Thread Nobody
On Sat, 22 May 2010 17:16:40 -0700, Lanny wrote:

> Ideally roomlist['start_room'].exits would equal {'aux_room' : 'west',
> 'second_room' : 'north'} but it doesn't. Sorry if this is unclear or too
> long, but I'm really stumped why it is giving bad output

Just to condense a point which the other responses don't (IMHO) make
particularly clear:

Unlike most other OO languages, Python doesn't make instance members
appear as variables within methods; you have to explicitly access them as
members of "self", i.e. "self.exits" for the "exits" member of the current
instance ("self").

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: where are the program that are written in python?

2010-05-23 Thread David Cournapeau
On Sun, May 23, 2010 at 5:19 PM, Lie Ryan  wrote:

> But the point still hold, that in real life, often the language's raw
> speed doesn't really limit the program's speed.

I would rather say that Python vs C does not matter until it does, and
it generally does when constants factor matter (which is one way to
draw the line between system programming and "general" programming).
It totally depends on the applications, I don't think you can draw
general arguments.

David
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: First Tkinter script: requesting comments

2010-05-23 Thread Peter Otten
Francesco Bochicchio wrote:

> One thing I don't understand, is why you need to 'poll' continuously
> for changes, except for demo purpose.

You can give the user immediate feedback on changes he makes. I'd argue that 
e. g. an "auto-apply" dialog with a revert button is much more usable and am 
surprised that this style hasn't caught on.

> If this is supposed to be a window for user to enter data into the
> program, the standard practice is to have a
> separate window (not the main one), with  apply and cancel buttons,
> where both buttons close the window but only
> the apply button register the change. So you need to do the stuff you
> do in the poll_exams function only in the
> callback of the apply button.

If you want live updates you can also use StringVar.trace() instead of 
polling:

from functools import partial

def grade_changed(name, index, var, *args):
new_grade = to_int(var.get())
if new_grade != exam_grades[index]:
exam_grades[index] = new_grade
print name, "-->", new_grade

pairs = zip(names, exam_grades_string)
for index, (name, var) in enumerate(pairs):
var.trace("w", partial(grade_changed, name, index, var))

See also http://effbot.org/tkinterbook/variable.htm

Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Urllib2: Only a partial page retrieved

2010-05-23 Thread hpsMouse
On 5月22日, 下午5时43分, Dragon Lord  wrote:
> The cutoff is allways at the same location: just after the label
> "Meeting date" and before the date itself. Could it be that something
> is interpreted as and eof command or something like that?
>
> example of the cutoff point with a bad page:
> Meeting Date: 
>
> example of the cutoff point with a good page:
> Meeting Date: 

I checked TCP packages, and found that the remote HTTP server send a
data package with flag "PUSH", causing the client to close connection.
That is exactly where the "Meeting Date: " appears.
This seems not to be a bug for python, because Qt and telnet both
failed in my test, so did the wget program...
Most browsers use keep-alive HTTP, so the connection won't be closed.
I think that's why a browser show the page correctly.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Urllib2: Only a partial page retrieved

2010-05-23 Thread hpsMouse
I know what the problem is.

Server checks client's locale setting to determine how the date should
be displayed. Python don't send locale information by default. So
server fails at that point.

If you add the following field in the HTTP request, the response will
be correct:
Accept-Language: en
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: where are the program that are written in python?

2010-05-23 Thread sturlamolden
On 23 Mai, 10:47, David Cournapeau  wrote:

> I would rather say that Python vs C does not matter until it does,

I disagree. C matters because it is portable assembly code. Which
means it is tedious and error prone to use, so avoiding it actually
matters. Hence C matters. Knowing when and when not to use C matters a
lot.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Urllib2: Only a partial page retrieved

2010-05-23 Thread Dragon Lord
Thanks, that works perfectly!

(oh and I learnt something new too, because I tried using telnet to
connect to the server :) )

On May 23, 11:42 am, hpsMouse  wrote:
> I know what the problem is.
>
> Server checks client's locale setting to determine how the date should
> be displayed. Python don't send locale information by default. So
> server fails at that point.
>
> If you add the following field in the HTTP request, the response will
> be correct:
> Accept-Language: en

-- 
http://mail.python.org/mailman/listinfo/python-list


logging: AttributeError: 'module' object has no attribute 'getLogger'

2010-05-23 Thread Frank GOENNINGER

Hi all:

Being completely new to Python still (just about a week into it now) I
tried to follow the Python 2.6.5 version documemtation aiming at setting
up a logger as follows:



import logging

global gPIBLogger

class PIBLogger(object):
'''
TODO: classdocs
'''

def __init__(self, logFileName):
'''
Constructor
'''
self.logFileName = logFileName
self.logger = logging.getLogger('PIBLogger')
self.logger.setLevel(logging.DEBUG)
handler = logging.handlers.RotatingFileHandler(self.logFileName, 
   maxBytes=100,
   backupCount=9)
self.logger.addHandler(handler)
gPIBLogger = self.logger
   

def main():
mylogger = PIBLogger('/tmp/pib.log')
gPIBLogger.debug(' Hi ')
   
if __name__ == "__main__":
main()



When trying to execute main() I get:

Traceback (most recent call last):
  File "/.../src/pib/logging.py", line 37, in 
main()
  File "/.../src/pib/logging.py", line 33, in main
mylogger = PIBLogger('/tmp/pib.log')
  File "/...src/pib/logging.py", line 23, in __init__
self.logger = logging.getLogger('PIBLogger')
AttributeError: 'module' object has no attribute 'getLogger'

I double checked and yes, getLogger is there. Why is the interpreter
asking for an "attribute" here ? Any hints on what I am doing wrong ?

TIA!

Regards

  Frank
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: logging: AttributeError: 'module' object has no attribute 'getLogger'

2010-05-23 Thread Simon Brunning
On 23 May 2010 14:46, Frank GOENNINGER  wrote:
> Traceback (most recent call last):
>  File "/.../src/pib/logging.py", line 37, in 
>    main()

Here's a clue - looks like your own module is called logging. That's
what's getting imported by your import. Try naming your module
something else, and you should be golden.

-- 
Cheers,
Simon B.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: logging: AttributeError: 'module' object has no attribute 'getLogger'

2010-05-23 Thread Philip Semanchuk


On May 23, 2010, at 9:46 AM, Frank GOENNINGER wrote:



Hi all:

Being completely new to Python still (just about a week into it now) I
tried to follow the Python 2.6.5 version documemtation aiming at  
setting

up a logger as follows:



import logging

global gPIBLogger

class PIBLogger(object):
   '''
   TODO: classdocs
   '''

   def __init__(self, logFileName):
   '''
   Constructor
   '''
   self.logFileName = logFileName
   self.logger = logging.getLogger('PIBLogger')
   self.logger.setLevel(logging.DEBUG)
   handler =  
logging.handlers.RotatingFileHandler(self.logFileName,
   
maxBytes=100,

  backupCount=9)
   self.logger.addHandler(handler)
   gPIBLogger = self.logger


def main():
   mylogger = PIBLogger('/tmp/pib.log')
   gPIBLogger.debug(' Hi ')

if __name__ == "__main__":
   main()



When trying to execute main() I get:

Traceback (most recent call last):
 File "/.../src/pib/logging.py", line 37, in 
   main()
 File "/.../src/pib/logging.py", line 33, in main
   mylogger = PIBLogger('/tmp/pib.log')
 File "/...src/pib/logging.py", line 23, in __init__
   self.logger = logging.getLogger('PIBLogger')
AttributeError: 'module' object has no attribute 'getLogger'

I double checked and yes, getLogger is there. Why is the interpreter
asking for an "attribute" here ? Any hints on what I am doing wrong ?



Short answer: Change the name of src/pib/logging.py to something else.

Long answer: When Python hits the line "import logging", it first  
looks in the current directory and imports logging.py, which in this  
case is the file it's already executing. It never finds the standard  
library's logging module.


One way you could have figured this out would be to add this as the  
first line of main():

   print dir(logging)

That would have told you what Python thought the logging module looked  
like, and would have perhaps recognized it as your own.


Cheers
Philip



--
http://mail.python.org/mailman/listinfo/python-list


Re: logging: AttributeError: 'module' object has no attribute 'getLogger'

2010-05-23 Thread Duncan Booth
Frank GOENNINGER  wrote:

> 
> When trying to execute main() I get:
> 
> Traceback (most recent call last):
>   File "/.../src/pib/logging.py", line 37, in 
> main()
>   File "/.../src/pib/logging.py", line 33, in main
> mylogger = PIBLogger('/tmp/pib.log')
>   File "/...src/pib/logging.py", line 23, in __init__
> self.logger = logging.getLogger('PIBLogger')
> AttributeError: 'module' object has no attribute 'getLogger'
> 
> I double checked and yes, getLogger is there. Why is the interpreter
> asking for an "attribute" here ? Any hints on what I am doing wrong ?
> 
You're source file appears to be called logging.py, so when you do 'import 
logging' it just imports itself. The system logging.py has a getLogger 
function, but *your* logging.py doesn't.
-- 
http://mail.python.org/mailman/listinfo/python-list


|help| python 3.12

2010-05-23 Thread Filipe
I'm with a problem I'm doing a program in python, it sends the
following error message:

File "C:/Documents and Settings/Filipe Vinicius/Desktop/Filipe/Cefet/
LP/Python/trab.sistema.academico/sistemaacademico.2010.5.23.c.py",
line 40, in administrador
lp = pickle.load(f)
  File "D:\Arquivos De Programa\Python31\lib\pickle.py", line 1365, in
load
encoding=encoding, errors=errors).load()
EOFError

What you need to do to repair this error? in my program at the part
where the error is find is that:

def administrador():
f = open('professores.dat', 'rb')
lp = pickle.load(f)
f.close()
...

Note: i had already imported the pikcle library
THX
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ugly modification of a class, can it be done better ?

2010-05-23 Thread Albert van der Horst
In article <[email protected]>,
Steven D'Aprano   wrote:
>Sorry for breaking threading, but Stef's original post has not come
>through to me.
>
>> On Thu, May 20, 2010 at 8:13 PM, Stef Mientki 
>> wrote:
>
>>> So I want to change the behavior of the class dynamically. I've done it
>>> by adding a global variable (Base_Grid_Double_Click) in the module,
>>> initial set to None,
>>> but can be changed by the main program to some callback function. (see
>>> the code below)
>
>How is this supposed to work? If you have *one* global, then *every*
>instance will see the same setting. To change it dynamically, you enter a
>nightmare world of having to save the global, modify it, then restore it,
>every single time. Trust me, I've been there, this is the *worst* way of
>programming. This is why object oriented inheritance was invented, to
>escape this nonsense!
>
>The first thing is to make the callback specific to the class, not
>global. Why does your printing code need access to the callback that
>handles double-clicking on a grid? It doesn't! So don't give it that
>access (at least, not easy access). Put the callback in the class.
>
>class MyClass:
>callback = None
>def method(self, *args):
>if self.callback is None:
>behaviour_with_no_callback()
>else:
>behaviour_with_callback()
>
>
>Now if you want to apply a callback to some instances, and not others, it
>is totally simple:
>
>
>red = MyClass()
>blue = MyClass()
>red.callback = my_callback_function
>
>and you're done.

Don't go overboard in complication.
Python can handle variable functions just fine, if that is the
proper solution to your problem. (In c they are called function
pointers and they are unruly.)

def a(b,c): return b+c
def p(q,r): return q*r
x=a
x(3,5)
8
x=p
x(3,5)
15



>--
>Steven

Sorry, but couldn't respond to the original message.
My newsserver doesn't have it anymore.

Groetjes Albert

--
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
alb...@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help (I can't think of a better title)

2010-05-23 Thread duncan smith

Alex Hall wrote:

On 5/22/10, MRAB  wrote:

Lanny wrote:

The answer may be right infront of me but I really can't figure this
out.
I'm trying to build a interactive fiction kind of game, silly I know
but I
am a fan of the genre. I'm trying to build up an index of all the
rooms in
the game from an outside file called roomlist.txt. The only problem is
that
every room ends up having four exits. Here's the code.


class room() :
room_id = 'room_id'
name = 'room'
description = 'description'
item_list =
exits = {}

 > visits = 0

These attributes are being defined as belonging to the class, so they
will be shared by all the instances of the class. This isn't a problem
for immutable items such as strings, but is for mutable items such as
dicts. In short, all the rooms share the same 'exits' dict.

You should really define the instance attributes (variables) in the
'__init__' method.


I just ran into something similar to this in my Battleship game. I had
a Craft class, which defined attributes for any craft (a recon plane,
a submarine, a battleship, and so on). One such attribute was a
weapons list, much like your exits dictionary; I would assign a couple
weapons to a battleship, but suddenly all my ships and airplanes had
those same weapons. What the great people on this list said to do was
something like this:

class Room():
 def __init__(self, exits):
  if exits==None:
   self.exits={}
  else:
   self.exits=exits

In this way, you can create a new Room object with exits,
r=Room(exits_dict)
or you can create a Room with no exits, and add them later:
r2=Room()
r2.exits["exit1"]="doorway"

but the code in the __init__ method, which will get called as soon as
you create a new Room object, ensures that passing an exits dictionary
will set that instance's exits to what was passed in, while passing
nothing will create a room with an empty dictionary (the if
statement). I hope this made some sense!


[snip]

It does when when you want 'exits' to take a default value which is a 
mutable type (and you don't want it shared by all instances).


class Room:
  def __init__(self, exits=None):
if exits is None:
  self.exits = {}
else:
  self.exits = exits

Otherwise, you're fine without the if ... else.

Duncan
--
http://mail.python.org/mailman/listinfo/python-list


Re: |help| python 3.12

2010-05-23 Thread Gary Herron

On 05/23/2010 08:13 AM, Filipe wrote:

I'm with a problem I'm doing a program in python, it sends the
following error message:

File "C:/Documents and Settings/Filipe Vinicius/Desktop/Filipe/Cefet/
LP/Python/trab.sistema.academico/sistemaacademico.2010.5.23.c.py",
line 40, in administrador
 lp = pickle.load(f)
   File "D:\Arquivos De Programa\Python31\lib\pickle.py", line 1365, in
load
 encoding=encoding, errors=errors).load()
EOFError

What you need to do to repair this error? in my program at the part
where the error is find is that:

def administrador():
 f = open('professores.dat', 'rb')
 lp = pickle.load(f)
 f.close()
 ...

Note: i had already imported the pikcle library
THX
   



EOFError means "End Of File".   The file you are reading in 
'professores.dat' must not contain a valid pickle -- perhaps it is 
empty, or created incorrectly.   But that's where to look.  Show us how 
you created that file.


Gary Herron


--
http://mail.python.org/mailman/listinfo/python-list


Re: How to show the current line number with pdb.set_trace()

2010-05-23 Thread Miki
Hello,

> After starting pdb.set_trace(), python doens't show line number. Could
> you let me know how to print the number by default so that I know
> where the current line is?
When you get the PDB prompt, just type "l". It'll show some code with
an error
on the current line.

You can also type "?" for help.

HTH,
--
Miki
-- 
http://mail.python.org/mailman/listinfo/python-list


MySQL, Python, NumPy and formatted read

2010-05-23 Thread Ian Hoffman
Hello,

I'm having significant Python difficulties (and I'm new to Python).
I'm trying to read BLOB ASCII (numerical) data from a MySQL database
using MySQLdb in a formatted fashion.  The BLOB data is a sequence of
numbers separated by newlines (\n), like this:
5
6
10
45
etc.

When I read the data using the fetchone() command I get a single
tuple.  What I'd like is to somehow put the tuple into a NumPy array
with each value as one element.  Then I can continue to do some
numerical processing.

Any advice/help?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQL, Python, NumPy and formatted read

2010-05-23 Thread Matteo Landi
I know anything about mysqldb and fetchone method, but it's easy to
create a numpy array, given a tuple of data:

>>> import numpy
>>>
>>> t = ('1', '2', '3')
>>> numpy.array(t, int)
array([1, 2, 3])
>>>

I made the assumption that mysqldb.fetchone return a tuple of strings,
so we need to create an array by specifying the type of the needed
values.

On Mon, May 24, 2010 at 12:30 AM, Ian Hoffman  wrote:
> Hello,
>
> I'm having significant Python difficulties (and I'm new to Python).
> I'm trying to read BLOB ASCII (numerical) data from a MySQL database
> using MySQLdb in a formatted fashion.  The BLOB data is a sequence of
> numbers separated by newlines (\n), like this:
> 5
> 6
> 10
> 45
> etc.
>
> When I read the data using the fetchone() command I get a single
> tuple.  What I'd like is to somehow put the tuple into a NumPy array
> with each value as one element.  Then I can continue to do some
> numerical processing.
>
> Any advice/help?
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Matteo Landi
http://www.matteolandi.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


python urllib mechanize post problem

2010-05-23 Thread ken
hello ALL

im making some simple python post script but it not working well.

there is 2 part to have to login.

first login is using 'http://mybuddy.buddybuddy.co.kr/userinfo/
UserInfo.asp' this one.

and second login is using 'http://user.buddybuddy.co.kr/usercheck/
UserCheckPWExec.asp'

i can login first login page, but i couldn't login second page
website.

and return some error 'illegal access' such like .

i heard this is related with some cooke but i don't know how to
implement to resolve this problem.

if anyone can help me much appreciated!! Thanks!

import re,sys,os,mechanize,urllib,time
import datetime,socket


params = urllib.urlencode({'ID':'ph896011', 'PWD':'pk1089' })
rq = mechanize.Request("http://mybuddy.buddybuddy.co.kr/userinfo/
UserInfo.asp", params)
rs = mechanize.urlopen(rq)
data = rs.read()

logged_fail = r';history.back();'  in
data
if not logged_fail:
 print 'login success'
 try:
  params = urllib.urlencode({'PASSWORD':'pk1089'})
  rq = mechanize.Request("http://user.buddybuddy.co.kr/usercheck/
UserCheckPWExec.asp", params )
  rs = mechanize.urlopen(rq)
  data = rs.read()
  print data
 except:
  print 'error'
-- 
http://mail.python.org/mailman/listinfo/python-list


Extended deadline (15 July 2010): CACS Singapore [EI Compendex,ISTP,IEEE Xplore]

2010-05-23 Thread Andrew
[ Please forward to those who may be interested. Thanks. ]
==
2010 International Congress on Computer Applications and Computational
Science
CACS 2010
http://irast.org/conferences/CACS/2010
4-6 December 2010, Singapore
==
CACS 2010 aims to bring together researchers and scientists from
academia, industry, and government laboratories to present new results
and identify future research directions in computer applications and
computational science. Topics of interest include, but are not limited
to:

Agent and Autonomous Systems
Computational Biology and Bioinformatics
Computer-Aided Design and Manufacturing
Computer Architecture and VLSI
Computer Control and Robotics
Computer Graphics, Animation and Virtual Reality
Computers in Education & Learning technology
Computer Modeling and Simulations
Computer Networks and Communications
Computer Security and Privacy
Computer Vision and Pattern Recognition
Data Mining and Data Engineering
Distributed and Services Computing
Energy and Power Systems
Intelligent Systems
Internet and Web Systems
Nano Technologies
Real-Time and Embedded Systems
Scientific Computing and Applications
Signal, Image and Multimedia Processing
Software Engineering
Test Technologies

CACS 2010 conference proceedings will be published by CPS which will
include the conference proceedings in IEEE Xplore and submit the
proceedings to Ei Compendex and ISTP for indexing.
Singapore's cultural diversity reflects its colonial history and
Chinese, Malay, Indian and Arab ethnicities. English is the dominant
official language, which is convenient for foreign visitors. Places of
interest, such as the Orchard Road district, Singapore Zoo, Night
Safari, and Sentosa, attract millions of visitors a year. Singapore is
a paradise for shopping, dinning, entertainment, and nightlife, with
two new integrated resorts.
Conference Contact: [email protected]
Paper Submission Deadline with Extended:  15 July 2010
Review Decision Notifications: 15 August 2010
Final Papers and Author Registration Deadline: 9 September 2010
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQL, Python, NumPy and formatted read

2010-05-23 Thread Ian Hoffman
On May 23, 6:54 pm, Matteo Landi  wrote:
> I know anything about mysqldb and fetchone method, but it's easy to
> create a numpy array, given a tuple of data:
>
>
>
> >>> import numpy
>
> >>> t = ('1', '2', '3')
> >>> numpy.array(t, int)
> array([1, 2, 3])
>
> I made the assumption that mysqldb.fetchone return a tuple of strings,
> so we need to create an array by specifying the type of the needed
> values.
>
>
>
> On Mon, May 24, 2010 at 12:30 AM, Ian Hoffman  wrote:
> > Hello,
>
> > I'm having significant Python difficulties (and I'm new to Python).
> > I'm trying to read BLOB ASCII (numerical) data from a MySQL database
> > using MySQLdb in a formatted fashion.  The BLOB data is a sequence of
> > numbers separated by newlines (\n), like this:
> > 5
> > 6
> > 10
> > 45
> > etc.
>
> > When I read the data using the fetchone() command I get a single
> > tuple.  What I'd like is to somehow put the tuple into a NumPy array
> > with each value as one element.  Then I can continue to do some
> > numerical processing.
>
> > Any advice/help?
>
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> --
> Matteo Landihttp://www.matteolandi.net/

The problem is the tuple is contained in a single value separated by
newlines (only a[0] has a record), otherwise I could do as you
suggest...

Isn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: where are the program that are written in python?

2010-05-23 Thread alex23
Gregory Ewing  wrote:
> I came across a game on Big Fish Games recently (it was
> "The Moonstone" IIRC) that appeared to have been built using
> Python and py2app.

Python tends to be used more for scripting internal game logic than
for every aspect of a game (which is, IMO, the right way to go about
it). It's not a huge list of commercial games that does this[1], but
it's a fairly classy one :)

1: http://en.wikipedia.org/wiki/Category:Python-scripted_video_games
-- 
http://mail.python.org/mailman/listinfo/python-list