RE: io module and pdf question

2013-06-25 Thread jyoung79
Thank you Rusi and Christian! So it sounds like I should read the pdf data in as binary: import os pdfPath = '~/Desktop/test.pdf' colorlistData = '' with open(os.path.expanduser(pdfPath), 'rb') as f: for i in f: if 'XYZ:colorList' in i:

io module and pdf question

2013-06-24 Thread jyoung79
Would like to get your opinion on this. Currently to get the metadata out of a pdf file, I loop through the guts of the file. I know it's not the greatest idea to do this, but I'm trying to avoid extra modules, etc. Adobe javascript was used to insert the metadata, so the added data looks

RE: Moving folders with content

2012-09-16 Thread jyoung79
Thank you Nobody and Hans! You may want to use the subprocess module to run 'ditto'. If the destination folder does not exist, then ditto will copy MacOS specific aspects such as resource forks, ACLs and HFS meta-data. This looks like a good direction to go. Maybe something like: import

RE: Moving folders with content

2012-09-16 Thread jyoung79
Hi Nobody and Hans, I really appreciate you all sharing this insight with me. You might think that os.path.expanduser would never expand '~' to something containing a double quote, but you'd be wrong: import os os.environ['HOME'] = 'gotcha!; rm -rf '

Moving folders with content

2012-09-14 Thread jyoung79
Hello, I am working in both OS X Snow Leopard and Lion (10.6.8 and 10.7.4). I'm simply wanting to move folders (with their content) from various servers to the hard drive and then back to different directories on the servers. I want to be careful not to remove any metadata or resource forks

RE: subprocess question

2011-12-12 Thread jyoung79
import subprocess p = subprocess.Popen(['du', '-sh'], cwd='/Users/jay/.Trash/', stdout=subprocess.PIPE) out, err = p.communicate() out ' 11M\t.\n' You might prefer to use subprocess.check_output(); it slightly simplifies your code:

subprocess question

2011-12-11 Thread jyoung79
Wondering if anyone could shed some light on the subprocess module? I'll admit I'm not that great at the shell. If I was wanting to get the size of the trash (on OS X), I could use: os.system('du -sh ~/.Trash/') 11M/Users/jay/.Trash/ 0 Which gives me what I want. However, I've been

RE: Ordered list question

2011-07-18 Thread jyoung79
Can you share a website that goes into more detail on this good variable naming? I'd Google that one. You'll find more articles than you can read in a lifetime... Very true! :-) -- http://mail.python.org/mailman/listinfo/python-list

Ordered list question

2011-07-17 Thread jyoung79
I'm currently working on a project where I'm looping through xml elements, pulling the 'id' attribute (which will be coerced to a number) as well as the element tag. I'm needing these elements in numerical order (from the id). Example xml might look like: price id=5 copyright id=1 address

Re: Ordered list question

2011-07-17 Thread jyoung79
Thank you Chris, Dan and Thomas for your replies. I really appreciate your insight, and I will look into the information you have given me. Dan, I've never heard of a treap or red-black tree, so I'll be interested to research these. Thomas, Thanks very much for giving me further knowledge

RE: Lambda question

2011-06-06 Thread jyoung79
f = lambda x, n, acc=[]: f(x[n:], n, acc+[(x[:n])]) if x else acc Packing tail recursion into one line is bad for both understanding and refactoring. Use better names and a docstring gives def group(seq, n): 'Yield from seq successive disjoint slices of length n plus the remainder'

Lambda question

2011-06-04 Thread jyoung79
I was surfing around looking for a way to split a list into equal sections. I came upon this algorithm: f = lambda x, n, acc=[]: f(x[n:], n, acc+[(x[:n])]) if x else acc f(Hallo Welt, 3) ['Hal', 'lo ', 'Wel', 't']

How does this work?

2011-06-04 Thread jyoung79
I was surfing around looking for a way to split a list into equal sections. I came upon this algorithm: f = lambda x, n, acc=[]: f(x[n:], n, acc+[(x[:n])]) if x else acc f(Hallo Welt, 3) ['Hal', 'lo ', 'Wel', 't']

renaming files in OS X

2011-04-20 Thread jyoung79
Hello, I'm considering using os.rename or shutil for renaming files on OS X (Snow Leopard). However, I've read that shutil doesn't copy the resource fork or metadata for the files on OS X. I'm not sure about os.rename though. I need to keep the resource fork and metadata. Is it better if

RE: renaming files in OS X

2011-04-20 Thread jyoung79
Not a Python question. You should go over to http://groups.google.com/group/comp.sys.mac.system/ and ask. -- Gnarlie What do you mean it's not a python question? os.rename is python syntax… how does it work on OS X? Is it the same as the 'mv' command, etc? Jay --

RE: renaming files in OS X

2011-04-20 Thread jyoung79
I'm considering using os.rename or shutil for renaming files on OS X (Snow Leopard)... Hi Jay, I don't know if os.rename() does what you want, but why don't you try a simple test and find out? Surely an empirical test is at least as useful as an answer from someone like me who may or

RE: renaming files in OS X

2011-04-20 Thread jyoung79
In article 280CB56A-89B8-4D62-9374-D769B3ACFEBB at semanchuk.com, Philip Semanchuk philip at semanchuk.com wrote: On Apr 20, 2011, at 10:02 AM, jyoung79 at kc.rr.com jyoung79 at kc.rr.com wrote: I'm considering using os.rename or shutil for renaming files on OS X (Snow Leopard

RE: Writing to a file

2011-03-28 Thread jyoung79
I appreciate you all taking the time to answer my question. These were the types of things I was needing to hear. Sorry for any confusion I may have caused by using a relative file path with the '~'… I was typing from memory and didn't think about it beforehand. Eryksun, thank you for the

Writing to a file

2011-03-25 Thread jyoung79
Just curious how others view the 2 examples below for creating and writing to a file in Python (in OS X). Is one way better than the other? If it was a large amount of text, would the 'os.system' call be a bad way to do it? Thanks. Jay f = open('~/Desktop/test.txt', 'w')

RE: python xmp toolkit question

2011-03-05 Thread jyoung79
In article 20110304161955.LI5T1.94538.root at cdptpa-web16-z02, jyoung79 at kc.rr.com wrote: Is anyone here using the Python XMP Toolkit? I'm trying to install this and having problems. I have no experience with either but I would guess that the two configure options are for building

python xmp toolkit question

2011-03-04 Thread jyoung79
Is anyone here using the Python XMP Toolkit? I'm trying to install this and having problems. First, I tried installing Exempi. The website says to do the following: ./configure make sudo make install but for Mac OS X they say to do one of these (I'm installing it on Leopard and hopefully

RE: Working with PDFs?

2010-08-23 Thread jyoung79
jyoung79 at kc.rr.com writes: - Pull out text from each PDF page (to search for specific words) - Combine separate pdf documents into one document - Add bookmarks (with destination settings) PDF Shuffler is a Python app which does PDF merging and splitting very well. I don't think it does

Working with PDFs?

2010-08-14 Thread jyoung79
Just curious if anyone knows if it's possible to work with pdf documents with Python? I'd like to do the following: - Pull out text from each PDF page (to search for specific words) - Combine separate pdf documents into one document - Add bookmarks (with destination settings) A few programs

BundleBuilder Question

2010-08-04 Thread jyoung79
I stumbled upon an article about bundlebuilder, so I was testing it a little. At first it wouldn't work and had this in the error: IOError: [Errno 2] No such file or directory: '/System/Library/Frameworks/Python.framework/Versions/2.6/Resources/English.lproj' I'm currently running OS X 10.6

tkinter unicode question

2010-07-27 Thread jyoung79
Just curious if anyone could shed some light on this? I'm using tkinter, but I can't seem to get certain unicode characters to show in the label for Python 3. In my test, the label and button will contain the same 3 characters - a Greek Alpha, a Greek Omega with a circumflex and soft

RE: drag drop in a python GUI application

2010-07-03 Thread jyoung79
Hi Alan, What OS are you running on? And by 'drag and drop' are you meaning you want to drag and drop on a GUI window, or are you wanting a droplet where you can drop your file/folder on the application icon? Jay -- Hello there, I know drag drop is not possible with TK. Which widget

RE: Continuously running scripts question

2010-06-28 Thread jyoung79
Thank you all very much for your replies. Appreciate your thoughts. I'll check this out. Thanks. Jay -- On 2010-06-25, Tim Harig usernet at ilthio.net wrote: It sounds to me, since your script is acting on an event, that it would benefit from using something like inotify, or whatever

Continuously running scripts question

2010-06-25 Thread jyoung79
Currently, I have some scripts (in particular, applescript 'stay-open' scripts) that run continuously on a Mac through the day. They look in a certain folder every 30 seconds and perform the necessary work needed. I was curious if anyone here on the list does anything similar with Python?

Re: GUIs - A Modest Proposal

2010-06-09 Thread jyoung79
On Wed, 2010-06-09 at 04:16 -0700, ant wrote: Since I started this thread, I feel a sense of responsibility for it, in some bizarre way. I'm glad you brought this GUI subject up. I've enjoyed reading everyones thoughts on this subject. Most people who have used a GUI have some investment

RE: [python] pass the name of args

2010-06-04 Thread jyoung79
Would vars() help? Check out this link: http://www.daniweb.com/forums/thread134555.html Jay -- def myDef(x) doSomething x result = x. return coolThings - WhatYourName = ('python','is','cool') myDef(WhatYourName) so what I am

RE:GUI programs

2010-05-30 Thread jyoung79
Just want to say thank you to all those who responded with their thoughts so far. Really appreciate you taking the time to share. This list has always been incredibly helpful and insightful! I do have another quick question. Has anyone had any luck getting PyGUI working on Snow Leopard? I

GUI programs

2010-05-29 Thread jyoung79
Just curious if anyone would be willing to share their thoughts about different Python GUI programming modules. I've been doing a bit of research and am trying to find something that: 1. Is portable. Would like to be able to send the module along with the main python file that would be able

pythonMagick question

2010-05-27 Thread jyoung79
Hello, I'm wanting to try out pythonMagick, but am pretty lost with this whole thing. What I'm wanting to do is view EPS and PDF files with Python and be able to zoom into the images to see smaller detail. I downloaded PythonMagick-0.9.1.tar and have been looking through that folder. The

Installing 3.1 questions

2009-06-01 Thread jyoung79
Can anyone give me info on what and where Python installs on OS X? I ran the installers for version 2.6 and 3.0 and only installed Python (not IDLE, etc). I then added this to my .profile: PATH=/Library/Frameworks/Python.framework/Versions/3.0/bin:${PATH}

Extract EPS info?

2009-05-13 Thread jyoung79
Just curious if Python has a built-in module for pulling data out of an EPS file? For example, I'd like to pull the text out of an EPS as well as the font names of the characters of the text. I believe I can pull all the font names from the header area, but was hoping Python might have

setting directory mod date

2009-03-24 Thread jyoung79
I've got some Python code (2.5.1) that's compressing folders on a Windows machine. When the directories get compressed, their modification date changes. Is it possible to grab the modification date of the folder before it's compressed, and then set it's modification date back to it's

datetime question

2009-03-06 Thread jyoung79
Just curious if this is the best way to get the first 3 letters of the current month? import datetime d = datetime.date.today() m = d.strftime(%B)[:3].upper() m 'MAR' Thanks. Jay -- http://mail.python.org/mailman/listinfo/python-list

change string to unicode

2008-12-19 Thread jyoung79
If I have a string like so: a = '\\u03B1' and I want to make it display a Greek alpha character, is there a way to convert it to unicode ('\u03B1')? I tried concatenating it like this: '\u' + '03B1' but that didn't work. I'm working in Python 3.0 and was curious if this could be done.

RE:change string to unicode

2008-12-19 Thread jyoung79
Hi Steven and Peter, Thank you both very much for taking the time to answer my question. Your solutions work perfect! :-) Thanks again! Jay How about \\u03b1.encode(ascii).decode(unicode-escape) 'α' Peter -- http://mail.python.org/mailman/listinfo/python-list

RE: applescript/python question

2008-08-02 Thread jyoung79
Hi Diez, Thanks for your reply. I gave this a try too, but it doesn't seem to work either. However, a gentleman just emailed me off-list recommending to use the full path to Python that is in /usr/local/bin. This is where Python 2.5 looks to be installed rather than Python 2.3 which is in

applescript/python question

2008-08-01 Thread jyoung79
I can't seem to figure this out. I just installed Python 2.5.2 a few days ago on my OS X 10.4.11 system. It runs fine and if I type Python -V in the Terminal it outputs Python 2.5.2 which is correct. However, if I try to run a 'do shell script' in AppleScript which I'm wanting to run a

RE:applescript/python question

2008-08-01 Thread jyoung79
Hi Sean, Thanks for your fast reply. This still doesn't seem to work. I also tried changing it to #!/usr/local/bin/python since it looks like the Python 2.5 items are actually in there. I'm starting to wonder if AppleScript's 'do shell script' command is actually looking in /usr/bin for

Re: elementtree and rounding questions

2008-07-30 Thread jyoung79
Thank you very much Gabriel and Stefan for your help! I really appreciate the excellent examples you've shared which is helping me understand how all this works. Again, thank you for taking the time to help me with this. Jay -- http://mail.python.org/mailman/listinfo/python-list

elementtree and rounding questions

2008-07-29 Thread jyoung79
Hi, Hoping that some of you won't mind taking a peek at my code and sharing your thoughts. I just started using the elementtree module yesterday to work with xml files. Here's an example of some xml code I might be parsing: data

Code question

2008-04-23 Thread jyoung79
Wow!! Thank you all for these incredible examples! I really appreciate you all taking the time to share your thoughts. I'm really wanting to learn efficient ways of programming in Python and this is really going to help! Thanks again! Jay --

Code question

2008-04-21 Thread jyoung79
I've been trying to figure out a way to combine lists similar to how zip() works. The main difference though is I want to work with different length lists and combine them. I came up with the example below, which returns a list like I'm wanting. I'm assuming it's somewhat efficient

RE:Get oldest folder

2008-04-16 Thread jyoung79
Hi Tim, Thanks very much for your help! I'm still just learning Python and really appreciate seeing other peoples examples on how they work with Python. Thanks again for taking the time to share this. Jay I'd like to be able to get the path to the oldest folder in whatever directory

Get oldest folder

2008-04-15 Thread jyoung79
I'd like to be able to get the path to the oldest folder in whatever directory I'm currently in. Is there a simple way to go about this? I'd like it to run on both OS X and Windows XP. I found this example at http://trac.v2v.cc/browser/python-v2v/v2v/v2v.py?rev=python-v2v%2C37;, but was

RE: question

2008-01-23 Thread jyoung79
Just wanted to say thanks to everyone for these helpful replies! I really appreciate it! :-) Jay -- http://mail.python.org/mailman/listinfo/python-list

question

2008-01-22 Thread jyoung79
I'm still learning Python and was wanting to get some thoughts on this. I apologize if this sounds ridiculous... I'm mainly asking it to gain some knowledge of what works better. The main question I have is if I had a lot of lists to choose from, what's the best way to write the code so I'm

RE: os.tmpfile()

2008-01-02 Thread jyoung79
It's a file. You read strings from it and write strings to it. It isn't a string itself. Given that what you're trying to do doesn't make any sense, it's hard to know where to begin to identify what's confusing you. -- Erik Max Francis Erik, I am going to be displaying sections of

os.tmpfile()

2008-01-01 Thread jyoung79
Can anyone elaborate on how 'os.tmpfile()' works? I was thinking it would create some sort of temporary file I could quickly add text too and then when I was finished would automatically get rid of it. Here's my questions: 1. Does it actually create a file somewhere? If so, where does it

RE:Windows XP unicode and escape sequences

2007-12-16 Thread jyoung79
Thank you John and Tim. With your help I found that the XP console code page is set up for 'cp437' and with a little bit of browsing I found that 869 is the code page for Modern Greek. After changing it to 869 that did the trick! Thanks very much for this advice. This brings up another

Windows XP unicode and escape sequences

2007-12-12 Thread jyoung79
I mainly work on OS X, but thought I'd experiment with some Python code on XP. The problem is I can't seem to get these things to work at all. First of all, I'd like to use Greek letters in the command prompt window, so I was going to use unicode to do this. But in the command prompt, the

RE:changing fonts?

2007-12-11 Thread jyoung79
Hi Greg, You can also use the MacOSX Character Palette to go hunting for unicode characters. You can get to it from Terminal using Special Characters... on the Edit menu. There's a search box down the bottom where you can enter part of the unicode name of a character, e.g. GREEK will get you

RE: changing fonts?

2007-12-09 Thread jyoung79
Hi Doug, I'm not *that* familiar with the Terminal program on OS/X, but regardless perhaps I can point out a possibly useful path to explore... Wow!! Thanks for all this info!! This is some good stuff!!! :-) Well, I got to experimenting with a lot of different stuff, as well as doing a

changing fonts?

2007-12-07 Thread jyoung79
This is probably a silly question, but alas, I'll ask it anyway... Is it possible with Python, to change the font of the text returned in the Terminal Window in OS X? For example, lets say I'm running a Python program in Terminal, and it asks me Please enter an English word to be changed to

changing fonts?

2007-12-07 Thread jyoung79
Hi Greg, Thanks for your fast reply. I apologize for my ignorance with unicode, but would you mind sharing an example of your experiment? Again, thanks for your help with this! Jay I don't think you can control the font, but you can print out the Greek text as utf8-encoded unicode. I just

RE:connect to server question

2007-12-04 Thread jyoung79
Hi Martin, Thanks very much for your help. This works perfect!! Jay Here's the code I presently use in a Bash Shell script: /bin/mkdir -p /Volumes/A_Share /sbin/mount_afp afp://username:[EMAIL PROTECTED]/A_Share /Volumes/A_Share Can something similar be done with Python? You

xml question

2007-09-12 Thread JYOUNG79
Just curious if there's any python xml parsing tools built into the Mac (OS 10.4.10 Tiger)? If so, could anyone share some simple code (or maybe point me to a web-site) of how to parse xml data from a file? For example, if I had a file that contained this: colors

RE:question

2007-08-27 Thread JYOUNG79
Hi MRAB, Thanks so much for taking the time to help me with this! I've learned a ton from the example you sent! I studied each part of your code so I could get a good understanding of how it worked. There was one question I had; on the regex line, you used (\d+)$ and I was curious why

question

2007-08-24 Thread JYOUNG79
Still trying to learn Python and was hoping some of you might be able to give me some advice on my code below. It works but I'm wondering if there's more efficient ways of doing this than the way I've done it. The first step is I have to loop thru nested folders and find all files that

RE:xlrd question

2007-08-06 Thread JYOUNG79
Hi Has, (as well as an alias to it from '/System/Library/Frameworks/Python.framework/ Versions/2.3/lib/python2.3/site-packages') No, /System.../python2.3/site-packages is a symlink to /Library/Python/ 2.3/site-packages set up by Apple. DistUtils makes no modification to anything under

xlrd question

2007-08-03 Thread JYOUNG79
When running 'python setup.py install' to install items for xlrd to work, does anybody know what items are installed and where items are installed at on a Mac (OS 10.4)? I'm assuming it mainly uses things out of the xlrd folder, but was curious if it copies files to other locations.

RE:xlrd question

2007-08-03 Thread JYOUNG79
Hi John, Thanks very much for your reply. And thanks for taking the time to create xlrd... this is a very cool and impressive program!! :-) I ran your code which gave me this: import sys, xlrd; print sys.version; print xlrd.__file__ 2.3.5 (#1, Jan 30 2006, 13:30:29) [GCC 3.3 20030304

RE:A few questions

2007-05-24 Thread JYOUNG79
Just wanted to send a quick Thank You! to everyone who helped answer my questions. This list is awesome!! I'm currently reading How to Think Like a Computer Scientist (thanks Basilisk96) and it's got some excellent tutorial info. I still want to take a look at Dive into Python as well as