Re: Problem in identifying an archived file in Windows

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 05:40:22 -0200, venu madhav escribió: I am writing an application which has to identify the archived files in a given directory.I've tried using the function i = win32api.GetFileAttributes (full_path) to obtain the attributes.But am unable to identify based on

Re: XML Parsing

2009-02-25 Thread hrishy
Hi Lie I am not a python guy but very interested in the langauge and i consider the people on this list to be intelligent and was wundering why you people did not suggest xpath for this kind of a problem just curious and willing to learn. I am searching for a answer but the question is why not

Re: pep 8 constants

2009-02-25 Thread Bruno Desthuilliers
Brendan Miller a écrit : PEP 8 doesn't mention anything about using all caps to indicate a constant. Is all caps meaning "don't reassign this var" a strong enough convention to not be considered violating good python style? I see a lot of people using it, but I also see a lot of people writing n

Re: pep 8 constants

2009-02-25 Thread Bruno Desthuilliers
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 wasn't already the case - I would have sweared it was. -- http://ma

Re: pep 8 constants

2009-02-25 Thread Bruno Desthuilliers
Brian Allen Vanderburg II a écrit : bock...@virgilio.it wrote: Constants would be a nice addition in python, sure enough. But I'm not sure that this can be done without a run-time check every time the constant is used, and python is already slow enough. Maybe a check that is disabled when runn

Re: pep 8 constants

2009-02-25 Thread Bruno Desthuilliers
Ethan Furman a écrit : Steve Holden wrote: Brian Allen Vanderburg II wrote: (snip) One idea to make constants possible would be to extend properties to be able to exist at the module level as well as the class level: @property def pi(): return 3.14159. print(pi) # prints 3.14159 p

variable length tuple assignment

2009-02-25 Thread Helmut Jarausch
Sorry if this is too simple but I couldn't find. I vaguely remember there is a means to assign a variable length tuple and catch the 'rest' like S="a,b,c,d" (A,B,) = S.split(',') I know I could do SL= split(',') (A,B)=SL[:2] Rest= SL[2:] but is there some shorthand for this? Many thanks for

Re: 'u' Obselete type – it is identical to 'd'. (7)

2009-02-25 Thread mathieu
On Feb 24, 11:06 pm, Steven D'Aprano wrote: > mathieu wrote: > > I did not know where to report that: > > > 'u' Obselete type – it is identical to 'd'. (7) > > >http://docs.python.org/library/stdtypes.html#string-formatting > > > Thanks > > If you google on "python bug tracker" the first

Re: 'u' Obselete type – it is identical to 'd'. (7 )

2009-02-25 Thread mathieu
On Feb 24, 9:24 pm, John Machin wrote: > On Feb 25, 4:48 am, mathieu wrote: > > > I did not know where to report that: > > > 'u' Obselete type – it is identical to 'd'. (7) > > >http://docs.python.org/library/stdtypes.html#string-formatting > > So what's your problem with that? Do you b

Re: variable length tuple assignment

2009-02-25 Thread Chris Rebert
On Wed, Feb 25, 2009 at 1:16 AM, Helmut Jarausch wrote: > Sorry if this is too simple but I couldn't find. > > I vaguely remember there is a means to assign a variable length tuple > and catch the 'rest'  like > > S="a,b,c,d" > > (A,B,) = S.split(',') In Python 3.0 (IIRC): A, B, *rest = S.split(

Re: pep 8 constants

2009-02-25 Thread Robin Becker
well this sort of awful hackery will allow you to put read only constants on an existing module >>> import reportlab >>> reportlab.__class__ >>> class MyModule(reportlab.__class__): ... @property ... def pi(self): ... return 3 ... >>> z=MyModule('reportlab') >>> z.__dict__.up

Re: Is there a way to increase memory allocated to the python interpreter

2009-02-25 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 janandith jayawardena wrote: > Is there a way to configure the amount of memory allocated to the python > interpreter. Can it be increased or decreased using an argument like in > the Java Virtual Machine. Java needs the memory allocation number beca

Re: Unix Change Passwd Python CGI

2009-02-25 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Derek Tracy wrote: > Apache is running on the same system that needs the password changed. I > need to keep security high and can not install additional modules at > this time. > > I just need a general direction to start looking, and I do not have >

Re: pep 8 constants

2009-02-25 Thread Bruno Desthuilliers
Robin Becker a écrit : well this sort of awful hackery will allow you to put read only constants on an existing module (snip example code) so I guess if you write your own module class and then use a special importer you can create module like objects with read only attributes. Fine tec

H-Index with Google Scholar

2009-02-25 Thread Gonsolo
I wrote a small script to compute the H-Index of an author. It is modeled after activestate's google search: http://code.activestate.com/recipes/523047/ Example use: hindex i daubechies Result: 49 The script: #!/usr/bin/python import httplib, urllib, re, sys from BeautifulSoup import BeautifulS

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

2009-02-25 Thread wongobongo
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, and sounds t

Re: pep 8 constants

2009-02-25 Thread Robin Becker
Bruno Desthuilliers wrote: Robin Becker a écrit : well this sort of awful hackery will allow you to put read only constants on an existing module (snip example code) so I guess if you write your own module class and then use a special importer you can create module like objects with read o

Re: reading file to list

2009-02-25 Thread nick_keighley_nospam
On 24 Feb, 15:00, nick_keighley_nos...@hotmail.com wrote: > On 17 Jan, 17:16, Xah Lee wrote: > > Here's a interesting toy problem posted by Drew Krause to > > comp.lang.lisp: > > > > > On Jan 16, 2:29 pm, Drew Krause wrote [paraphrased a bit]: > > > OK, I want to create a

Re: reading file to list

2009-02-25 Thread nick_keighley_nospam
On 17 Jan, 17:16, Xah Lee wrote: > comp.lang.lisp,comp.lang.scheme,comp.lang.functional,comp.lang.python,comp.­lang.ruby > The lisp's cons fundamentally makes nested list a pain to work with. > Lisp's nested syntax makes functional sequencing cumbersome. so hide it (define (make-list stream e

Re: variable length tuple assignment

2009-02-25 Thread Tim Chase
Chris Rebert wrote: On Wed, Feb 25, 2009 at 1:16 AM, Helmut Jarausch wrote: Sorry if this is too simple but I couldn't find. I vaguely remember there is a means to assign a variable length tuple and catch the 'rest' like S="a,b,c,d" (A,B,) = S.split(',') In Python 3.0 (IIRC): A, B, *rest

PyCrypto AES MODE_CBC - How to?

2009-02-25 Thread Helmut Jarausch
Hi, I've just tried to write a simple example using PyCrypto's AES (CBC mode) #!/usr/bin/python from Crypto.Cipher import AES PWD='abcdefghijklmnop' Initial16bytes='0123456789ABCDEF' crypt = AES.new(PWD, AES.MODE_CBC,Initial16bytes) # crypt = AES.new(PWD, AES.MODE_ECB) txt = 'ea523a664dabaa44

Lambda function

2009-02-25 Thread aditya saurabh
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 -- http://mail.python.org/mailman/listinfo/python-list

Re: PyCrypto AES MODE_CBC - How to?

2009-02-25 Thread Helmut Jarausch
Helmut Jarausch wrote: Hi, I've just tried to write a simple example using PyCrypto's AES (CBC mode) #!/usr/bin/python from Crypto.Cipher import AES PWD='abcdefghijklmnop' Initial16bytes='0123456789ABCDEF' crypt = AES.new(PWD, AES.MODE_CBC,Initial16bytes) # crypt = AES.new(PWD, AES.MODE_ECB)

Re: XML Parsing

2009-02-25 Thread J. Clifford Dyer
Probably because you responded an hour after the question was posted, and in the dead of night. Newsgroups often move slower than that. But now we have posted a solution like that, so all's well in the world. :) Cheers, Cliff On Wed, 2009-02-25 at 08:20 +, hrishy wrote: > Hi Lie > > I am

Re: Convert PySerial to python 3.0

2009-02-25 Thread Seth
On Feb 24, 10:55 pm, Chris Rebert wrote: > On Tue, Feb 24, 2009 at 7:46 PM, Seth wrote: > > I am just messing around trying to get pyserial to work with 3.0. > > > I am stuck on this line: > > > if type(port) in [type(''), type(u'')] > > > how can I convert this to 3.0? I tried changing the u to

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

2009-02-25 Thread Christian Meesters
Hoi, 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 function. Well, no

Free Python Training

2009-02-25 Thread Steve Holden
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.blogspot.com/2009/02/free-python-training.html

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

2009-02-25 Thread David Cournapeau
On Wed, Feb 25, 2009 at 9:40 PM, Christian Meesters wrote: > Hoi, > > 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

sorting tasks by importance and urgency

2009-02-25 Thread Alia Khouri
I recently considered the apparently simple problem is of how to algorithmically sort a set of business tasks which have an associated a value and a due_date, such that the most important and urgent are pushed to the top of the stack. The two example task types I am posing here are: (1) a bid on a

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

2009-02-25 Thread rdmurray
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.message_from_string method. > > > > In particular, email.message_from_string() does not seem to pro

Re: Convert PySerial to python 3.0

2009-02-25 Thread Christian Heimes
Seth wrote: > I implemented "if isinstance(port, str): " that seems to work for now. > > Currently I am running into: > > err, n = win32file.WriteFile(self.hComPort, data, > self._overlappedWrite) > TypeError: expected an object with a buffer interface Unicode objects (in Py3k: str) don't implem

Re: Python Imaging Library (PIL): create PDF from scratch

2009-02-25 Thread zelegolas
Like David said now i used PIL for individual images and reportlab to generate a pdf. Thanks for your advices :) -- http://mail.python.org/mailman/listinfo/python-list

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

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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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

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

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).'''

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

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.

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: 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

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: 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

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: 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

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: 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: 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: 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: 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: 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

"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: "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

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: 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: 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: "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: "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: 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: 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: 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

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 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

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: "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: 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: 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 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: 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: 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 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: "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: 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

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 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,

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: "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 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 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

  1   2   >