Re: class property not working in python 2.5.1

2009-02-25 Thread Christian Heimes
Dan Barbus schrieb: > Hi, > > I have a problem with setting a property to a class instance, in > python 2.5.1. The property is defined through get and set methods, but > when I set it, the setter doesn't get called. Instead, I believe the > property in the instance gets replaced with a new object

class property not working in python 2.5.1

2009-02-25 Thread Dan Barbus
Hi, I have a problem with setting a property to a class instance, in python 2.5.1. The property is defined through get and set methods, but when I set it, the setter doesn't get called. Instead, I believe the property in the instance gets replaced with a new object (string). I have the following

Re: PYTHONPATH on Mac 10.5

2009-02-25 Thread Python Nutter
+1 for site packages and standard shebang, still lets you launch with python first followed by .py file or followed by .py file also for some clues, just open up a terminal in your Mac OS X computer and check out your exports your PATH will be different depending on all the software and developme

Re: Queries

2009-02-25 Thread Gary Herron
mmcclaf wrote: I have to make some queries for 4 tables I have. The following relations are: Classes(class, type, country, numGuns, bore, displacement) Ships (name, class, launched) Battles (name, date) Outcomes (ship, battle, result) The three queries I'm stuck on are the following: 1. Find

Re: XML Parsing

2009-02-25 Thread hrishy
Hi Cliff Thanks so using elementree is the right way to handle this problem regards Hrishy --- On Wed, 25/2/09, J. Clifford Dyer wrote: > From: J. Clifford Dyer > Subject: Re: XML Parsing > To: hris...@yahoo.co.uk > Cc: python-list@python.org, "Lie Ryan" > Date: Wednesday, 25 February, 2009

Re: XML Parsing

2009-02-25 Thread hrishy
Ha the guru himself responding :-) --- On Wed, 25/2/09, Paul McGuire wrote: > From: Paul McGuire > Subject: Re: XML Parsing > To: python-list@python.org > Date: Wednesday, 25 February, 2009, 2:04 PM > On Feb 25, 1:17 am, hrishy > wrote: > > Hi > > > > Something like this > > > > > > > Note i

Re: File Path retrieving problem

2009-02-25 Thread John Machin
On Feb 26, 3:16 pm, music24...@gmail.com wrote: > On Feb 26, 9:03 am, Steve Holden wrote: > > > > > music24...@gmail.com wrote: > > > On Feb 26, 2:35 am, Emile van Sebille wrote: > > >> Peter Otten wrote: > > >>> Maybe it's about access rights? > > >>> $ mkdir alpha > > >>> $ touch alpha/beta > >

Re: File Path retrieving problem

2009-02-25 Thread music24by7
On Feb 26, 9:03 am, Steve Holden wrote: > music24...@gmail.com wrote: > > On Feb 26, 2:35 am, Emile van Sebille wrote: > >> Peter Otten wrote: > >>> Maybe it's about access rights? > >>> $ mkdir alpha > >>> $ touch alpha/beta > >>> $ python -c"import os; print os.path.exists('alpha/beta')" > >>>

Queries

2009-02-25 Thread mmcclaf
I have to make some queries for 4 tables I have. The following relations are: Classes(class, type, country, numGuns, bore, displacement) Ships (name, class, launched) Battles (name, date) Outcomes (ship, battle, result) The three queries I'm stuck on are the following: 1. Find the classes that

Re: File Path retrieving problem

2009-02-25 Thread Steve Holden
music24...@gmail.com wrote: > On Feb 26, 2:35 am, Emile van Sebille wrote: >> Peter Otten wrote: >>> Maybe it's about access rights? >>> $ mkdir alpha >>> $ touch alpha/beta >>> $ python -c"import os; print os.path.exists('alpha/beta')" >>> True >>> $ chmod u-x alpha >>> $ python -c"import os; pri

Re: File Path retrieving problem

2009-02-25 Thread music24by7
On Feb 26, 2:35 am, Emile van Sebille wrote: > Peter Otten wrote: > > Maybe it's about access rights? > > > $ mkdir alpha > > $ touch alpha/beta > > $ python -c"import os; print os.path.exists('alpha/beta')" > > True > > $ chmod u-x alpha > > $ python -c"import os; print os.path.exists('alpha/beta

Re: Using cPickle

2009-02-25 Thread mmcclaf
Thanks! All fixed! -- http://mail.python.org/mailman/listinfo/python-list

thread safe to lock on key,val pairs on a dict instead of entire dict?

2009-02-25 Thread birdsong
Dictionaries just store references to objects, right? So is it thread safe to lock a specific key/val pair on a dictionary and modify its val and release the lock? example snippet: # assuming d_lock was initialized long ago in a thread-safe manner d_lock.acquire() d = {} d[1] = (threading.Lock()

Is this the right way to use unicode in a user defined Exception?

2009-02-25 Thread 一首诗
# class MyError(Exception): def __init__(self): self.message = u'Some Chinese:中文' def __str__(self): return self.message.encode('utf8') # This is an exception that I defined.

Re: "Battleship" style game

2009-02-25 Thread Zvezdan Petkovic
On Feb 25, 2009, at 3:54 PM, Shawn Milochik wrote: It is true that it would be fewer lines of code with the same functionality, but it's better practice to have that framework in place so that any changes made in the future wouldn't break any of the code accessing my class. Obviously this is a fa

Re: Python Image Library IOError - cannot find JPEG decoder?

2009-02-25 Thread Zvezdan Petkovic
On Feb 24, 9:34 am, Dario Traverso wrote: I've been trying to install the Python Image Library (PIL) on my Mac OSX Leopard laptop, but have been running into some difficulties. ... I've followed all of the installation instructions exactly. The build summary reported everything was "ok". What c

Re: variables bound in moudules are None when module is not completely imported

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 21:24:33 -0200, escribió: On Wed, Feb 25, 2009 at 05:05:28PM -0200, Gabriel Genellina wrote: I'd try to move all the global stuff in that module into a function, "init". Importing the module will always succeed - you have to manually call init() after importing it. i nor

Re: pep 8 constants

2009-02-25 Thread Rhodri James
On Wed, 25 Feb 2009 08:48:27 -, Bruno Desthuilliers wrote: Ben Finney a écrit : (snip - about using ALL_CAPS for pseudo-constants) Perhaps I'd even argue for an update to PEP 8 that endorses this as conventional. +1 I've been a bit surprised last time I checked PEP8 to find out this

Re: reading file to list

2009-02-25 Thread Xah Lee
On Feb 25, 10:18 am, Xah Lee wrote: > On Feb 25, 3:34 am, nick_keighley_nos...@hotmail.com wrote: > > > the nasty cons then only appears in a single function which > > you can hide in a library > > I think the following answers that. > > Q: If you don't like cons, lisp has arrays and hashmaps, too

Re: PYTHONPATH on Mac 10.5

2009-02-25 Thread Philip Semanchuk
On Feb 25, 2009, at 3:20 PM, Vincent Davis wrote: I have looked around for a good howto setup PYTHONPATH on Mac os x 10.5 Although I get many results I am not sure which is correct. I am not sure if it is different for 10.5 over previous versions. Does anyone know of a well documented set

Re: This application has failed to start because the application configuration is incorrect

2009-02-25 Thread Mark Hammond
On 26/02/2009 4:51 AM, Lorenzo wrote: PS: Mark, this could be added to a kind of "Deployment" entry in py2exe wiki, it would be useful. IIRC, I've never edited the py2exe wiki (despite appearances to the contrary sometimes, I don't formally maintain that package!). But that is the cool thin

logging.Handler not working with QThreads

2009-02-25 Thread Lukas Hetzenecker
Hello, I created a QTextEdit where I wanted to display log messages. A logging.Handler should do this job. It worked with one thread well, but when I start a QThread the text on all widgets is removed and I get many errors in my konsole: X Error: RenderBadGlyphSet (invalid GlyphSet parameter) 1

Re: variables bound in moudules are None when module is not completely imported

2009-02-25 Thread chrysn
On Wed, Feb 25, 2009 at 05:05:28PM -0200, Gabriel Genellina wrote: > I'd try to move all the global stuff in that module into a function, > "init". Importing the module will always succeed - you have to manually > call init() after importing it. i normally do that anyway and would also have do

Re: python sql query in django

2009-02-25 Thread Diez B. Roggisch
for a introduction to the multitude of query-options. I doubt that your rather simple m:n-relationship is covered there. s/is/isn't/ Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: python sql query in django

2009-02-25 Thread Diez B. Roggisch
I think Django is fabulous for the admin-interface, a simple text search and template inheritance. I will use Django for all of those. What I'm not getting an answer to and cannot find an example of is a complex search, where I have to retrieve data from multiple tables, combine the data, remove

Re: variable length tuple assignment

2009-02-25 Thread Steven D'Aprano
Tim Chase wrote: > As an aside, as of the last time I read the PEP[1] on this, I > believe it exhausts (or attempts to exhaust) any iterator. IMHO, > I think this exhausting is a bad idea because it prevents things like > >def numbers(start=0): > i = start > while True: >yi

Re: "Battleship" style game

2009-02-25 Thread Jean-Paul Calderone
On Wed, 25 Feb 2009 15:54:46 -0500, Shawn Milochik wrote: On Wed, Feb 25, 2009 at 3:15 PM, Diez B. Roggisch wrote: Not really. The point about properties is that you *can* make attribute access trigger getter or setter code. But not that you do unless there is an actual reason for that. The

Re: [Tutor] Accessing callers context from callee method

2009-02-25 Thread mobiledreamers
i found the solution This is my first attempt at memcaching html page using cheetah since cheetah render needs locals() i use getCallerInfo() to get the locals() and send to memcached let me know if it is possible to better do this *notice getCallerInfo * *utils.py* @log_time_func def renderpage(k

Re: Python Image Library IOError - cannot find JPEG decoder?

2009-02-25 Thread OdarR
On 24 fév, 18:34, Dario Traverso wrote: > I've been trying to install the Python Image Library  (PIL) on my Mac   > OSX Leopard laptop, but have been running into some difficulties. > > I've built the library, using the included setup.py  script. The build   > summary checks out ok, and sounds the

Re: python sql query in django

2009-02-25 Thread Bruno Desthuilliers
May a écrit : On Feb 24, 10:36 am, "Diez B. Roggisch" wrote: Thanks for all your suggestions. From what I've experienced in Django and now that I know a little more about how Python functions, I will probably use a combination of PHP and Django, instead of trying to get Python to do the web po

Re: "Battleship" style game

2009-02-25 Thread Grant Edwards
On 2009-02-25, Diez B. Roggisch wrote: > Don't waste time coding for a future you can't even pretend to > know. Do what is needed to solve the actual problem. Premature obfuscation is even worse than premature optimization. -- Grant Edwards grante Yow! Well, O.K.

Re: File Path retrieving problem

2009-02-25 Thread Emile van Sebille
Peter Otten wrote: Maybe it's about access rights? $ mkdir alpha $ touch alpha/beta $ python -c"import os; print os.path.exists('alpha/beta')" True $ chmod u-x alpha $ python -c"import os; print os.path.exists('alpha/beta')" False $ I Don't know how this is handled on Windows... Here's one w

Re: "Battleship" style game

2009-02-25 Thread Diez B. Roggisch
Shawn Milochik schrieb: On Wed, Feb 25, 2009 at 3:15 PM, Diez B. Roggisch wrote: Not really. The point about properties is that you *can* make attribute access trigger getter or setter code. But not that you do unless there is an actual reason for that. The way you do it now is simply introdu

Re: "Battleship" style game

2009-02-25 Thread J. Cliff Dyer
On Wed, 2009-02-25 at 15:54 -0500, Shawn Milochik wrote: > On Wed, Feb 25, 2009 at 3:15 PM, Diez B. Roggisch wrote: > > > Not really. The point about properties is that you *can* make attribute > > access trigger getter or setter code. > > > > But not that you do unless there is an actual reason

Re: "Battleship" style game

2009-02-25 Thread Steve Holden
Shawn Milochik wrote: > On Wed, Feb 25, 2009 at 3:15 PM, Diez B. Roggisch wrote: > >> Not really. The point about properties is that you *can* make attribute >> access trigger getter or setter code. >> >> But not that you do unless there is an actual reason for that. The way you >> do it now is s

Re: "Battleship" style game

2009-02-25 Thread Shawn Milochik
On Wed, Feb 25, 2009 at 3:15 PM, Diez B. Roggisch wrote: > Not really. The point about properties is that you *can* make attribute > access trigger getter or setter code. > > But not that you do unless there is an actual reason for that. The way you > do it now is simply introducing clutter, with

Re: Python Image Library IOError - cannot find JPEG decoder?

2009-02-25 Thread Irmen de Jong
wongobongo wrote: On Feb 24, 9:34 am, Dario Traverso wrote: I've been trying to install the Python Image Library (PIL) on my Mac OSX Leopard laptop, but have been running into some difficulties. I've built the library, using the included setup.py script. The build summary checks out ok,

PYTHONPATH on Mac 10.5

2009-02-25 Thread Vincent Davis
I have looked around for a good howto setup PYTHONPATH on Mac os x 10.5 Although I get many results I am not sure which is correct. I am not sure if it is different for 10.5 over previous versions. Does anyone know of a well documented set of instructions. In my python scripts I specify which pytho

Re: Python dictionary size/entry limit?

2009-02-25 Thread Martin v. Löwis
>> On a 32-bit system, the dictionary can have up to 2**31 slots, >> meaning that the maximum number of keys is slightly smaller >> (about 2**30). > > Which, in practice, means that the size is limited by the available memory. Right. Each slot takes 12 bytes, so the storage for the slots alone wo

Re: "Battleship" style game

2009-02-25 Thread Diez B. Roggisch
Shawn Milochik schrieb: Thanks. I wasn't aware of the property() function, but I read up on it. I modified the Vessels.py file, but not the board file (except where necessary to handle the changes made to Vessels. Is this better? http://shawnmilo.com/ships/ships2/ Not really. The point about

Re: Free Python Training: Washington, DC (3/3-5)

2009-02-25 Thread Steve Holden
Alan G Isaac wrote: > Great idea, but if you do it again, a bit > more lead time would be helpful. > Appreciate that. Last-minute idea. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman

Re: coding style - try, except

2009-02-25 Thread RGK
I'm glad I asked :) Thanks all who posted for your replies, the else-statement is a nice option. Python again comes through to deal with those pesky feelings that something could be better :) Ross. Chris Rebert wrote: Yes. try-except-*else*. try: do_something_1() do_something

Re: Free Python Training: Washington, DC (3/3-5)

2009-02-25 Thread Alan G Isaac
Great idea, but if you do it again, a bit more lead time would be helpful. Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: variables bound in moudules are None when module is not completely imported

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 16:48:16 -0200, escribió: update: i've found one, but this only works if the exception is raised at a point determined by the outside. to explain why this is applicable: in the examples, i used `1/0` to raise a zero division exception inside the module whose scope i want to

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 16:19:35 -0200, Thorsten Kampe escribió: * Tim Golden (Wed, 25 Feb 2009 17:27:07 +) Thorsten Kampe wrote: > * Gabriel Genellina (Wed, 25 Feb 2009 14:00:16 -0200) >> En Wed, 25 Feb 2009 13:40:31 -0200, Thorsten Kampe [...] >>> And I wonder why you would think the header

Re: variables bound in moudules are None when module is not completely imported

2009-02-25 Thread chrysn
On Tue, Feb 24, 2009 at 03:27:19PM +0100, chr...@fsfe.org wrote: > * is there a workaround? > * especially, is there a workaround that works w/o rewriting the > modules that raise the exceptions? (otherwise, wrapping all the > stuff called in the __name__=="__main__" wrapper into a

Re: "Battleship" style game

2009-02-25 Thread Shawn Milochik
Thanks. I wasn't aware of the property() function, but I read up on it. I modified the Vessels.py file, but not the board file (except where necessary to handle the changes made to Vessels. Is this better? http://shawnmilo.com/ships/ships2/ -- http://mail.python.org/mailman/listinfo/python-list

Re: coding style - try, except

2009-02-25 Thread Christian Heimes
RGK wrote: > Any input appreciated :) How about: import logging try: # run your function some_function() except Exception: # except only the exceptions you *really* want to catch # at most you should except "Exception" since it doesn't # catch KeyboardInterrupt and SystemExit l

Re: coding style - try, except

2009-02-25 Thread Scott David Daniels
RGK wrote: I'm still learning, so eager to see if there is some community wisdom about use of the try/except structures in this situation try: do something 1 do something 2 do something 3 do something 4 ... do something 25 except: print "Oops something didn't

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 15:44:18 -0200, escribió: Tab is not mentioned in RFC 2822 except to say that it is a valid whitespace character. Header folding (insertion of ) can occur most places whitespace appears, and is defined in section 2.2.3 thusly: [...] So, the whitespace characters are suppose

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread Thorsten Kampe
* Tim Golden (Wed, 25 Feb 2009 17:27:07 +) > Thorsten Kampe wrote: > > * Gabriel Genellina (Wed, 25 Feb 2009 14:00:16 -0200) > >> En Wed, 25 Feb 2009 13:40:31 -0200, Thorsten Kampe [...] > >>> And I wonder why you would think the header contains Unicode characters > >>> when it says "us-ascii

Re: reading file to list

2009-02-25 Thread Xah Lee
On Feb 25, 3:34 am, nick_keighley_nos...@hotmail.com wrote: > the nasty cons then only appears in a single function which > you can hide in a library I think the following answers that. Q: If you don't like cons, lisp has arrays and hashmaps, too. A: Suppose there's a lang called gisp. In gisp,

Re: coding style - try, except

2009-02-25 Thread Peter Otten
Steve Holden wrote: > RGK wrote: >> >> I'm still learning, so eager to see if there is some community wisdom >> about use of the try/except structures in this situation. >> >> I find myself with some potentially risky stuff and wrap it in a >> try/except structure with good functional results, t

Re: coding style - try, except

2009-02-25 Thread Chris Rebert
On Wed, Feb 25, 2009 at 9:36 AM, RGK wrote: > > I'm still learning, so eager to see if there is some community wisdom about > use of the try/except structures in this situation. > > I find myself with some potentially risky stuff and wrap it in a try/except > structure with good functional results

Re: glibc detected *** python: corrupted double-linked list

2009-02-25 Thread Duncan Grisby
In article , David Cournapeau wrote: [...] >It is very unlikely the problem is in glibc - I would check your code >carefully first :) On Linux, the following are useful: You are right that it is extremely unlikely that the bug is in glibc. However, it is not impossible. Several of my colleagues

Re: This application has failed to start because the application configuration is incorrect

2009-02-25 Thread Lorenzo
On 17 feb, 19:44, Mark Hammond wrote: > On 18/02/2009 5:49 AM, Sam Clark wrote: > > > I am receiving the message "Thisapplicationhasfailedtostartbecause > > theapplicationconfiguration is incorrect" when I attempt to run a > > compiled Python program on another machine. I have used py2exe on both

Re: coding style - try, except

2009-02-25 Thread Steve Holden
RGK wrote: > > I'm still learning, so eager to see if there is some community wisdom > about use of the try/except structures in this situation. > > I find myself with some potentially risky stuff and wrap it in a > try/except structure with good functional results, though my code leaves > me a b

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread Steve Holden
rdmur...@bitdance.com wrote: [...] > >The process of moving from this folded multiple-line representation >of a header field to its single line representation is called >"unfolding". Unfolding is accomplished by simply removing any CRLF >that is immediately followed by WSP. Each h

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread rdmurray
Steve Holden wrote: > rdmur...@bitdance.com wrote: > > Steve Holden wrote: > > from email.header import decode_header > > print > >> decode_header("=?us-ascii?Q?Inteum_C/SR_User_Tip:__Quick_Access_to_Recently_Opened_Inteu?=\r\n\t=?us-ascii?Q?m_C/SR_Records?=") > >> [('Inteum C/SR User Tip

coding style - try, except

2009-02-25 Thread RGK
I'm still learning, so eager to see if there is some community wisdom about use of the try/except structures in this situation. I find myself with some potentially risky stuff and wrap it in a try/except structure with good functional results, though my code leaves me a bit uneasy. Maybe it'

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 15:01:08 -0200, Thorsten Kampe escribió: * Gabriel Genellina (Wed, 25 Feb 2009 14:00:16 -0200) En Wed, 25 Feb 2009 13:40:31 -0200, Thorsten Kampe escribió: > * Roy H. Han (Wed, 25 Feb 2009 10:17:22 -0500) >> Thanks, RDM, for stating the right approach. >> Thanks, Steve, fo

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread Tim Golden
Thorsten Kampe wrote: * Gabriel Genellina (Wed, 25 Feb 2009 14:00:16 -0200) En Wed, 25 Feb 2009 13:40:31 -0200, Thorsten Kampe escribió: * Roy H. Han (Wed, 25 Feb 2009 10:17:22 -0500) Thanks, RDM, for stating the right approach. Thanks, Steve, for teaching by example. I wonder why the email

Re: File Path retrieving problem

2009-02-25 Thread Peter Otten
Steve Holden wrote: > What, you are saying that > > os.path.exists(filename) > > is returning false when the file exists? I find that hard to believe. > > Please display some evidence so I can understand this. Maybe it's about access rights? $ mkdir alpha $ touch alpha/beta $ python -c"import

Re: "Battleship" style game

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 14:50:18 -0200, Shawn Milochik escribió: On Wed, Feb 25, 2009 at 11:38 AM, Marco Mariani wrote: Yes it's in Python alright, but it's not Pythonese yet. You could try avoiding the getter/setter stuff, and camelCase method naming, things like that, for a start. What d

Re: "Battleship" style game

2009-02-25 Thread Steve Holden
Shawn Milochik wrote: > On Wed, Feb 25, 2009 at 11:38 AM, Marco Mariani wrote: >> Yes it's in Python alright, but it's not Pythonese yet. You could try >> avoiding the getter/setter stuff, and camelCase method naming, things like >> that, for a start. >> >> -- >> http://mail.python.org/mailman/lis

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread Thorsten Kampe
* Gabriel Genellina (Wed, 25 Feb 2009 14:00:16 -0200) > En Wed, 25 Feb 2009 13:40:31 -0200, Thorsten Kampe > escribió: > > * Roy H. Han (Wed, 25 Feb 2009 10:17:22 -0500) > >> Thanks, RDM, for stating the right approach. > >> Thanks, Steve, for teaching by example. > >> > >> I wonder why the emai

Re: File Path retrieving problem

2009-02-25 Thread Steve Holden
music24...@gmail.com wrote: > On Feb 25, 8:57 pm, Steve Holden wrote: >> music24...@gmail.com wrote: >>> Hi all, >>> I am new to Python, i have installed python 2.5.4 and it is my >>> requirement. >>> I need to retrieve the path of filename in python. >>> I have found some API's to get this: >>> f

Re: "Battleship" style game

2009-02-25 Thread Shawn Milochik
On Wed, Feb 25, 2009 at 11:38 AM, Marco Mariani wrote: > > Yes it's in Python alright, but it's not Pythonese yet. You could try > avoiding the getter/setter stuff, and camelCase method naming, things like > that, for a start. > > -- > http://mail.python.org/mailman/listinfo/python-list > What d

Re: "Battleship" style game

2009-02-25 Thread Marco Mariani
Shawn Milochik wrote: > I'm not claiming it's bulletproof, but it works. I just kind of came up with all the methods off of the top of my head, so if anyone has any suggestions for more elegant or efficient code, please let me know. Yes it's in Python alright, but it's not Pythonese yet. You

"Battleship" style game

2009-02-25 Thread Shawn Milochik
I started learning Java for fun, and the first project assignment in the book is to create a game like "Battleship." So, of course, I wrote it in Python first, just for fun. I haven't had the time to look up all the Java syntax. So, here it is, fully functional. I thought I'd throw it out there an

Re: Convert PySerial to python 3.0

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 14:07:30 -0200, Seth escribió: This is not my code and I am fairly new to Python. I did not know how much it would take to convert pyserial to 3.0. Someone more knowledgeable than me could do it better and faster. I just want to see if I could help get it to work. The la

Re: File Path retrieving problem

2009-02-25 Thread music24by7
On Feb 25, 8:57 pm, Steve Holden wrote: > music24...@gmail.com wrote: > > Hi all, > > > I am new to Python, i have installed python 2.5.4 and it is my > > requirement. > > > I need to retrieve the path of filename in python. > > > I have found some API's to get this: > > > from os.path import real

Re: How to convert image into numpy.ndarray

2009-02-25 Thread Christian Meesters
On Wed, 25 Feb 2009 07:52:03 -0800, anti-suho wrote: > In scipy module, there is a function named misc.lena which can return an > array of numpy.ndarray type. If you use this array as parameter of > matplotlib.pyplot.imshow and then call the matplotlib.pyplot.imshow > function, an image will be sh

Re: glibc detected *** python: corrupted double-linked list

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 13:51:20 -0200, Christian Meesters escribió: I have a problem using my software on my 64bit laptop, after an update of my system. The same code still runs on 32bit Intel, but on my laptop I provoke the crash in the title. The crash is caused - as narrowed down by me - by r

Re: Convert PySerial to python 3.0

2009-02-25 Thread Seth
This is not my code and I am fairly new to Python. I did not know how much it would take to convert pyserial to 3.0. Someone more knowledgeable than me could do it better and faster. I just want to see if I could help get it to work. I was wrong, it seems that if type(port) in (str, bytes): or i

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 13:40:31 -0200, Thorsten Kampe escribió: * Roy H. Han (Wed, 25 Feb 2009 10:17:22 -0500) Thanks, RDM, for stating the right approach. Thanks, Steve, for teaching by example. I wonder why the email.message_from_string() method doesn't call email.header.decode_header() auto

Re: File Path retrieving problem

2009-02-25 Thread Steve Holden
music24...@gmail.com wrote: > Hi all, > > I am new to Python, i have installed python 2.5.4 and it is my > requirement. > > I need to retrieve the path of filename in python. > > I have found some API's to get this: > > from os.path import realpath > print realpath("NEWS.txt") # here NEWS.txt

How to convert image into numpy.ndarray

2009-02-25 Thread anti-suho
In scipy module, there is a function named misc.lena which can return an array of numpy.ndarray type. If you use this array as parameter of matplotlib.pyplot.imshow and then call the matplotlib.pyplot.imshow function, an image will be shown. The shown image is generated by the numpy.ndarray array.

Re: glibc detected *** python: corrupted double-linked list

2009-02-25 Thread Christian Meesters
Hi, >> I have a problem using my software on my 64bit laptop, after an update >> of my system. The same code still runs on 32bit Intel, but on my laptop >> I provoke the crash in the title. The crash is caused - as narrowed >> down by me - by returning a static PyObject from a C-extension >> funct

Re: Newbie : this works in one direction but get the error on the return path

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 13:31:25 -0200, Gary Wood escribió: Start looking at the error: Traceback (most recent call last): File "E:/python/handson/backAndForth4.py", line 97, in main() File "E:/python/handson/backAndForth4.py", line 90, in main moveAllOnLine(faceList, -dx, dy, stepsAc

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread Thorsten Kampe
* Roy H. Han (Wed, 25 Feb 2009 10:17:22 -0500) > Thanks, RDM, for stating the right approach. > Thanks, Steve, for teaching by example. > > I wonder why the email.message_from_string() method doesn't call > email.header.decode_header() automatically. And I wonder why you would think the header co

File Path retrieving problem

2009-02-25 Thread music24by7
Hi all, I am new to Python, i have installed python 2.5.4 and it is my requirement. I need to retrieve the path of filename in python. I have found some API's to get this: from os.path import realpath print realpath("NEWS.txt") # here NEWS.txt exists and it shows the path of the file as C:\Pyt

Re: glibc detected *** python: corrupted double-linked list

2009-02-25 Thread Christian Meesters
Thanks David! It's still not debugged, but indeed: I get a bunch of warnings. And this already showed me that there are more potential problems than my first guess indicated. Alas, for my specific problem I cannot work with ints chars and doubles. I need to have unsigned longs at some points.

Re: glibc detected *** python: corrupted double-linked list

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 10:40:23 -0200, Christian Meesters escribió: I have a problem using my software on my 64bit laptop, after an update of my system. The same code still runs on 32bit Intel, but on my laptop I provoke the crash in the title. The crash is caused - as narrowed down by me - by r

Newbie : this works in one direction but get the error on the return path

2009-02-25 Thread Gary Wood
'''Test animation of a group of objects making a face. Combine the face elements in a function, and use it twice. Have an extra level of repetition in the animation. ''' from graphics import * import time def moveAll(shapeList, dx, dy): ''' Move all shapes in shapeList by (dx, dy).'''

File Path retrieving problem

2009-02-25 Thread Sudhir Kakumanu
Hi all, I am new to Python, i have installed python 2.5.4 and it is my requirement. I need to retrieve the path of filename in python. I have found some API's to get this: from os.path import realpath print realpath("NEWS.txt") # here NEWS.txt exists and it shows the path of the file as C:\Pyt

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread Steve Holden
rdmur...@bitdance.com wrote: > Steve Holden wrote: > from email.header import decode_header > print >> decode_header("=?us-ascii?Q?Inteum_C/SR_User_Tip:__Quick_Access_to_Recently_Opened_Inteu?=\r\n\t=?us-ascii?Q?m_C/SR_Records?=") >> [('Inteum C/SR User Tip: Quick Access to Recently Opene

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread Roy H. Han
Cool, it works! Thanks, RDM, for stating the right approach. Thanks, Steve, for teaching by example. I wonder why the email.message_from_string() method doesn't call email.header.decode_header() automatically. On Wed, Feb 25, 2009 at 9:50 AM, wrote: > Steve Holden wrote: >> >>> from email.he

Re: Convert PySerial to python 3.0

2009-02-25 Thread Christian Heimes
Seth wrote: > I tried all three ways you guys listed nothing seems to convert the > string to bytes. > > It may have to do with the makeDeviceName function, but I can't find > where that is defined. > > Any thoughts?? > > Here is the whole block of code: > > if type(port) in (str, bytes):

Re: Lambda function

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 12:42:32 -0200, Albert Hopkins escribió: On Wed, 2009-02-25 at 17:56 +0530, aditya saurabh wrote: I defined two functions - lets say fa = lambda x: 2*x fb = lambda x: 3*x Now I would like to use fa*fb in terms of x is there a way? Thanks in advance I'm not sure what "us

Re: Convert PySerial to python 3.0

2009-02-25 Thread Seth
I tried all three ways you guys listed nothing seems to convert the string to bytes. It may have to do with the makeDeviceName function, but I can't find where that is defined. Any thoughts?? Here is the whole block of code: if type(port) in (str, bytes): #strings are taken directly Origi

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread rdmurray
Steve Holden wrote: > >>> from email.header import decode_header > >>> print > decode_header("=?us-ascii?Q?Inteum_C/SR_User_Tip:__Quick_Access_to_Recently_Opened_Inteu?=\r\n\t=?us-ascii?Q?m_C/SR_Records?=") > [('Inteum C/SR User Tip: Quick Access to Recently Opened Inteum C/SR > Records', 'us-asc

Re: Extending Python Questions .....

2009-02-25 Thread Ben
On Feb 24, 11:31 am, Nick Craig-Wood wrote: > Ben wrote: > >  No, It uses the the S-lang for video, and input control. However, SLAG > >  is more of an abstract layer on top of that. > > >  It has a Structures that contains menus and screens (menumodule / > >  screenmodule). One LOADS them up wit

Re: Lambda function

2009-02-25 Thread Albert Hopkins
On Wed, 2009-02-25 at 17:56 +0530, aditya saurabh wrote: > I defined two functions - lets say > fa = lambda x: 2*x > fb = lambda x: 3*x > Now I would like to use fa*fb in terms of x > is there a way? > Thanks in advance I'm not sure what "use fa*fb in terms of x" means. But if you mean fa(x) * fb

Re: Python dictionary size/entry limit?

2009-02-25 Thread Stefan Behnel
Martin v. Löwis wrote: > intellimi...@gmail.com wrote: >> Is there a limit to the size or number of entries that a single >> dictionary can possess? > > On a 32-bit system, the dictionary can have up to 2**31 slots, > meaning that the maximum number of keys is slightly smaller > (about 2**30). W

Re: Free Python Training: Washington, DC (3/3-5)

2009-02-25 Thread Aahz
In article , Steve Holden wrote: > >Not a joke, but a genuine offer extended to anyone who has already >contributed to some open source project. See my blog for full details, >and please pass this on to non-Python programmers who are interested in >learning the language. > > http://holdenweb.blo

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread Steve Holden
Roy H. Han wrote: > On Wed, Feb 25, 2009 at 8:39 AM, wrote: [Top-posting corrected] >> John Machin wrote: >>> On Feb 25, 11:07=A0am, "Roy H. Han" >>> wrote: Dear python-list, I'm having some trouble decoding an email header using the standard imaplib.IMAP4 class and email.me

Re: How do I decode unicode characters in the subject using email.message_from_string()?

2009-02-25 Thread Roy H. Han
Thanks for writing back, RDM and John Machin. Tomorrow I'll try the code you suggested, RDM. It looks quite helpful and I'll report the results. In the meantime, John asked for more data. The sender's email client is Microsoft Outlook 11. The recipient email client is Lotus Notes. Actual Su

Re: XML Parsing

2009-02-25 Thread Paul McGuire
On Feb 25, 1:17 am, hrishy wrote: > Hi > > Something like this > > > Note i am not a python programmer just a enthusiast and i was curious why > people on the list didnt suggest a code like above > You just beat the rest of us to it - good example of ElementTree for parsing XML (and I Iearned t

Re: Forwarding keyword arguments from one function to another

2009-02-25 Thread Ravi
Thnak you all. > In the future, explain "didn't work". > Wrong output? give actual (copy and paste) and expected. > Error message? give traceback (copy and paste). I will be careful. -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >