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:
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
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
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 '
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
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:
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
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
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
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
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'
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']
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']
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
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
--
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
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
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
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')
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
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
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
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
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
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
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
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
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?
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
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
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
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
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
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}
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
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
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
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.
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
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
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
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
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
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
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
--
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
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
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
Just wanted to say thanks to everyone for these helpful replies! I really
appreciate it! :-)
Jay
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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.
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
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
66 matches
Mail list logo