Re: String To List

2008-03-17 Thread Jeff Schwab
Girish wrote: > I have a string a = "['xyz', 'abc']".. I would like to convert it to a > list with elements 'xyz' and 'abc'. Is there any simple solution for > this?? Do you want: (1) Specifically to vivify lists formatted as in your example? If so, why? (2) To save and restore arbitrary python

Re: python-list Metaquestion

2008-03-17 Thread Jeff Schwab
Tom Stambaugh wrote: > I continue to receive emails, addressed to [EMAIL PROTECTED], > with subject: "Re: Your message to Python-list awaits moderator approval", > which read: > >> Your mail to 'Python-list' with the subject >> >>(no subject) >> >> Is being held until the list moderator can

Re: Missing PyObject definition

2008-03-17 Thread Jeff Schwab
James Whetstone wrote: > I'm trying to access a PyObject directly from C++ for the purpose of calling > method on a Python object that is an intance of a derived C++ class. My > problem is that the compiler is complaining about not PyObject not being > defined. Has anyone run into the problem?

Re: questions about named pipe objects...

2008-03-17 Thread Jeff Schwab
waltbrad wrote: > I'm proceeding slowly though the Lutz book "Programming Python". I'm > in the section on named pipes. The script he uses has two functions: > one for the child the other for the parent. You start the parent then > the child: > > python pipefifo.py #starts the parent > > file /

Re: Interesting math problem

2008-03-17 Thread Jeff Schwab
BJörn Lindqvist wrote: > Here is an interesting math problem: > > You have a number X > 0 and another number Y > 0. The goal is to > divide X into a list with length Y. Each item in the list is an > integer. The sum of all integers is X. Each integer is either A or A + > 1, those should be "evenly

Re: About reading Python code

2008-03-17 Thread Jeff Schwab
sturlamolden wrote: > On 17 Mar, 04:54, WaterWalk <[EMAIL PROTECTED]> wrote: > >> So I'm curious how to read code effectively. I agree that python code >> is clear, but when it becomes long, reading it can still be a hard >> work. > > First, I recommend that you write readable code! Don't use Pyt

Re: Interesting math problem

2008-03-17 Thread Jeff Schwab
Arnaud Delobelle wrote: > On Mar 17, 10:24 pm, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: >> Here is an interesting math problem: >> >> You have a number X > 0 and another number Y > 0. The goal is to >> divide X into a list with length Y. Each item in the list is an >> integer. The sum of all in

Re: Any fancy grep utility replacements out there?

2008-03-17 Thread Jeff Schwab
[EMAIL PROTECTED] wrote: > So I need to recursively grep a bunch of gzipped files. This can't be > easily done with grep, rgrep or zgrep. (I'm sure given the right > pipeline including using the find command it could be donebut > seems like a hassle). > > So I figured I'd find a fancy next g

Re: First Program Bug (Newbie)

2008-03-17 Thread Jeff Schwab
Benjamin Serrato wrote: > P.S. What is the chance I'll get spam for using my real email address? Fendi Chef Bag in Zucca Print - Black Trim Replica AAA, Fake HandBags Cheap Chef Bag in Zucca Print - Black Trim Bags Link : http://www.cnreplicas.com/Fendi_1439.html Chef Bag in Zucca Print - Black

Re: Interesting math problem

2008-03-18 Thread Jeff Schwab
Marc Christiansen wrote: > sturlamolden <[EMAIL PROTECTED]> wrote: >> On 18 Mar, 00:58, Jeff Schwab <[EMAIL PROTECTED]> wrote: >> >>> def make_slope(distance, parts): >>> if parts == 0: >>> return [] >>> >>

Re: PyCon Feedback and Volunteers (Re: Pycon disappointment)

2008-03-18 Thread Jeff Schwab
Mike Driscoll wrote: > On Mar 18, 1:41 pm, fumanchu <[EMAIL PROTECTED]> wrote: >> On Mar 17, 6:25 pm, dundeemt <[EMAIL PROTECTED]> wrote: >> >>> I agree - the balance wasn't as good. We can all agree that HowTos >>> and Intros are a necessary part of the conference talks track, but as >>> Robert p

ftp recursively

2008-03-18 Thread Jeff Schwab
I need to move a directory tree (~9GB) from one machine to another on the same LAN. What's the best (briefest and most portable) way to do this in Python? I see that urllib has some support for getting files by FTP, but that it has some trouble distinguishing files from directories. http

Re: ftp recursively

2008-03-18 Thread Jeff Schwab
Gabriel Genellina wrote: > En Tue, 18 Mar 2008 18:25:28 -0300, Jeff Schwab <[EMAIL PROTECTED]> > escribió: > >> I need to move a directory tree (~9GB) from one machine to another on >> the same LAN. What's the best (briefest and most portable) way to do >>

Re: Is there a way to get __thismodule__?

2008-03-18 Thread Jeff McNeil
ssage): number = 1 class MessageTwo(Message): number = 2 class MessageFourThousandThreeHundredAndTwentyTwoPointOne(Message): number = 4322.1 print MetaMessage.nmap Which results in: mac:~ jeff$ !p python test.py {1: , 2: , 4322.10004: } mac:~ jeff$ Thanks! Jeff On 3/19/08

Re: ftp recursively

2008-03-19 Thread Jeff Schwab
Paul Rubin wrote: > Jeff Schwab <[EMAIL PROTECTED]> writes: >> ftping it as a flat file, and untarring it on the other side. Of >> course, the motivation wasn't just to get the files from point A to >> point B using Unix (which I already know how to do), but to tak

Re: Change user on UNIX

2008-03-20 Thread Jeff Schwab
Jonathan Gardner wrote: > On Mar 20, 4:51 am, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: >> Is there any way to su or login as a different user within a python >> script? I mainly need to temporarily impersonate another user to >> execute a command and then come back to the original user. > I

Re: Can I run a python program from within emacs?

2008-03-20 Thread Jeff Schwab
Grant Edwards wrote: > On 2008-03-20, jmDesktop <[EMAIL PROTECTED]> wrote: > >> Hi, I'm trying to learn Python. I using Aquamac an emac >> implementation with mac os x. I have a program. If I go to the >> command prompt and type pythong myprog.py, it works. Can the program >> be run from withi

Re: Can I run a python program from within emacs?

2008-03-20 Thread Jeff Schwab
jmDesktop wrote: > On Mar 20, 11:21 am, Grant Edwards <[EMAIL PROTECTED]> wrote: >> On 2008-03-20, jmDesktop <[EMAIL PROTECTED]> wrote: >> >>> Hi, I'm trying to learn Python. I using Aquamac an emac >>> implementation with mac os x. I have a program. If I go to the >>> command prompt and type py

Re: Can I run a python program from within emacs?

2008-03-20 Thread Jeff Schwab
Paulo da Costa wrote: > People who say Emacs often mean GNU Emacs. That's funny; to me, Emacs usually means XEmacs. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Can I run a python program from within emacs?

2008-03-20 Thread Jeff Schwab
Grant Edwards wrote: > On 2008-03-20, Jeff Schwab <[EMAIL PROTECTED]> wrote: > >>>> http://www.google.com/search?q=emacs+python >>> Gee. Thanks. >> I believe Grant was suggesting that Emacs often serves a similar purpose >> on Unix to what Visual St

Re: An Application Program to Play a CD

2008-03-20 Thread Jeff McNeil
I don't know of any Python specific stuff to do this, but have you looked at Asterisk? I know it's quite configurable and allows you to setup dial plans and route extensions and whatnot. http://www.asterisk.org/ That's probably a better fit. On 3/20/08, W. Watson <[EMAIL PROTECTED]> wrote: > How

Re: List question

2008-03-22 Thread Jeff Schwab
Zentrader wrote: > On Mar 22, 10:07 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: >> On Mar 22, 4:38 pm, Zentrader <[EMAIL PROTECTED]> wrote: >> if ('one', 'two') are in f: ... >>> "are" gives me an error in Python 2.5 with a "from future import *" >>> statement included. What version and p

Re: Do any of you recommend Python as a first programming language?

2008-03-22 Thread Jeff Schwab
jmDesktop wrote: > For students 9th - 12th grade, with at least Algebra I. Do you think > Python is a good first programming language for someone with zero > programming experience? Using Linux and Python for first exposure to > programming languages and principles. Linux and Python are a nearly

Re: Do any of you recommend Python as a first programming language?

2008-03-22 Thread Jeff Schwab
Larry Bates wrote: > jmDesktop wrote: >> For students 9th - 12th grade, with at least Algebra I. Do you think >> Python is a good first programming language for someone with zero >> programming experience? Using Linux and Python for first exposure to >> programming languages and principles. >> >>

Re: Do any of you recommend Python as a first programming language?

2008-03-22 Thread Jeff Schwab
Arnaud Delobelle wrote: > Anyway, here the conclusion that I draw: learn lambda-calculus and > Turing machines. The rest is syntactic sugar. How is the lambda-calculus fundamentally different from Turing machine-based implementations? I've been learning a fair amount about functional programmi

Re: Time module is not behaving.

2008-03-26 Thread Jeff Lofaro
dow a Python library module. Gary Herron > *print time.time()* > > And this is what happens when I run it > > [EMAIL PROTECTED]:~/tmp$ python time.py > > Traceback (most recent call last): > File "time.py", line 1, in > import time >

Re: Egg deinstallation

2009-01-12 Thread Jeff McNeil
development or toying with different eggs. When you're done, simply blow away the environment. I've used it for just about everything over the past few months, it's a wonderful tool. Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple CGI-XMLRPC failure

2009-01-12 Thread Jeff McNeil
On Jan 12, 12:40 pm, "Mike MacHenry" wrote: > I am having a difficult time understanding why my very simple > CGI-XMLRPC test isn't working. I created a server to export two > functions, the built-in function "pow" and my own identity function > "i". I run a script to call both of them and the "po

Re: Simple CGI-XMLRPC failure

2009-01-13 Thread Jeff McNeil
I don't have the version in front of me now as that was on my home machine, but Python was the same right down to the revision number. Unless you've mucked with it, it's the same file that I've got on my box. Jeff On Jan 13, 10:51 am, "Mike MacHenry" wrote: >

tp_base, ob_type, and tp_bases

2009-01-17 Thread Jeff McNeil
omewhere? Or perhaps someone can give me a quick explanation? Thanks! Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: tp_base, ob_type, and tp_bases

2009-01-17 Thread Jeff McNeil
from object. > > Regards, > Martin Thank you! It was tp_base that was confusing me. The tp_bases member makes sense as Python supports multiple inheritance. It wasn't immediately clear that tp_base is there for single inheritance reasons. It's all quite clear now. Is that an optimization of sorts? Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: tp_base, ob_type, and tp_bases

2009-01-17 Thread Jeff McNeil
On Jan 17, 11:09 am, Jeff McNeil wrote: > On Jan 17, 10:50 am, "Martin v. Löwis" wrote: > > > > > > So, the documentation states that ob_type is a pointer to the type's > > > type, or metatype. Rather, this is a pointer to the new type's >

Re: Socket issues

2009-01-17 Thread Jeff McNeil
second thing I usually do? 'setenforce 0.' Also, by "doesn't work", what do you mean? Does it just hang and never reply? Do you get a connection refused message? Jeff mcjeff.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: tp_base, ob_type, and tp_bases

2009-01-18 Thread Jeff McNeil
On Jan 18, 5:40 am, Carl Banks wrote: > On Jan 17, 8:12 am, Jeff McNeil wrote: > > > > > On Jan 17, 11:09 am, Jeff McNeil wrote: > > > > On Jan 17, 10:50 am, "Martin v. Löwis" wrote: > > > > > > So, the documentation states that ob_t

Re: *Advanced* Python book?

2009-01-19 Thread Jeff McNeil
On Jan 18, 6:35 pm, Simon Brunning wrote: > 2009/1/17 Michele Simionato : > > > "Expert Python Programming" by Tarek Ziadé is quite good and I wrote > > a review for it: > > >http://www.artima.com/weblogs/viewpost.jsp?thread=240415 > > +1 for this. I'm 3/4 of the way through it, it's pretty good.

Re: Doubts related to subprocess.Popen()

2009-01-20 Thread Jeff McNeil
lts in: Traceback (most recent call last): File "test.py", line 9, in stderr=subprocess.PIPE)) File "/usr/lib/python2.5/subprocess.py", line 593, in __init__ errread, errwrite) File "/usr/lib/python2.5/subprocess.py", line 1002, in _execute_child errp

Re: Trouble writing txt

2009-01-21 Thread Jeff McNeil
On Jan 21, 1:59 pm, bilgin arslan wrote: > Hello, > I am trying to write a list of words to into a text file as two > colons: word (tab) len(word) > such as > > standart8 > > I have no trouble writing the words but I couldn't write integers. I > always get strange characters, such as: > > GUN

Re: list subsetting

2009-01-21 Thread Jeff McNeil
uot;help", "copyright", "credits" or "license" for more information. >>> [1,2,3,3.14,3.14,5,66].count(3.14) 2 >>> Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: Executing previous stack frame

2009-01-22 Thread Jeff McNeil
code_object.co_filename, code_object.co_name, code_object.co_firstlineno, code_object.co_lnotab) exec c in globals() threading.Thread(target=tmain).start() do_something_we_should_not_do() # Anything below here will run in both threads. print threading.current_thr

Re: really slow gzip decompress, why?

2009-01-26 Thread Jeff McNeil
On Jan 26, 10:22 am, redbaron wrote: > I've one big (6.9 Gb) .gz file with text inside it. > zcat bigfile.gz > /dev/null does the job in 4 minutes 50 seconds > > python code have been doing the same job for 25 minutes and still > doesn't finish =( the code is simpliest I could ever imagine: > > de

Re: really slow gzip decompress, why?

2009-01-26 Thread Jeff McNeil
On Jan 26, 10:51 am, Jeff McNeil wrote: > On Jan 26, 10:22 am, redbaron wrote: > > > I've one big (6.9 Gb) .gz file with text inside it. > > zcat bigfile.gz > /dev/null does the job in 4 minutes 50 seconds > > > python code have been doing the same job for 25 m

Re: How to execute a hyperlink?

2009-01-28 Thread Jeff McNeil
'webbrowser' module. If you're looking to simply trigger a GET/POST without the UI aspect, then you'll probably want urllib or urllib2. Thanks, Jeff mcjeff.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Want to write a script to do the batch conversion from domain name to IP.

2009-01-30 Thread Jeff McNeil
On Jan 30, 7:33 am, Chris Rebert wrote: > On Fri, Jan 30, 2009 at 4:27 AM, Hongyi Zhao wrote: > > Hi all, > > > Suppose I've the entries like the following in my file: > > > -- > > 116.52.155.237:80 > > ip-72-55-191-6.static.privatedns.com:3128 > > 222.124.135.40:80 > > 217.151.23

easy_install

2009-02-08 Thread hall . jeff
For the life of me I can not figure out how to get easy_install to work. The syntax displayed on the web page does not appear to work properly. easy_install c:\MySQL_python-1.2.2-py2.4-win32.egg Is there a simpler way to install a python egg? Or am I missing something with easy_install? -- http:/

Re: easy_install

2009-02-08 Thread hall . jeff
On Feb 8, 9:27 am, "Diez B. Roggisch" wrote: > hall.j...@gmail.com wrote: > > For the life of me I can not figure out how to get easy_install to > > work. The syntax displayed on the web page does not appear to work > > properly. > > > easy_install c:\MySQL_python-1.2.2-py2.4-win32.egg > > It usua

Re: easy_install

2009-02-09 Thread hall . jeff
I had it downloaded and sitting in the root c:\ but didn't get it to run because I didn't think about the \scripts folder not being in the Path. Problem solved and fixed. Thank you all for your help. On a side note, "easy_install MySQL-python" produced the following messages: Searching for MySQL-p

SVN/CVS and Branching

2009-02-18 Thread Jeff Dyke
Hello. I am curious about different ideas on how you handle branching your python projects. With some other languages this is trivial, but since python uses these directories as modules and i have the top level module starting imports all over the place, i am wondering what others do. In the pas

Re: SVN/CVS and Branching

2009-02-19 Thread Jeff Dyke
this is to create a branch, say foo2, and create a symbolic link named foo pointing at foo2, after renaming foo, when i want to work on the branch and remove the link when i want to work on the head. This actually works fine, but thought there may be a better way. Jeff On Wed, Feb 18, 2009 at 7

Re: SVN/CVS and Branching

2009-02-19 Thread Jeff Dyke
On Thu, Feb 19, 2009 at 7:57 AM, David Stanek wrote: > On Thu, Feb 19, 2009 at 7:10 AM, Jeff Dyke wrote: >> Fair enough. Say my project is called foo, and it has many >> submodules. So there are imports that may look like `import foo.bar` >> or `from foo.bar import baz`

unicode and hashlib

2008-11-28 Thread Jeff H
hashlib.md5 does not appear to like unicode, UnicodeEncodeError: 'ascii' codec can't encode character u'\xa6' in position 1650: ordinal not in range(128) After googling, I've found BDFL and others on Py3K talking about the problems of hashing non-bytes (i.e. buffers) http://www.mail-archive.com/

Re: unicode and hashlib

2008-11-29 Thread Jeff H
On Nov 28, 1:24 pm, Scott David Daniels <[EMAIL PROTECTED]> wrote: > Jeff H wrote: > > hashlib.md5 does not appear to like unicode, > >   UnicodeEncodeError: 'ascii' codec can't encode character u'\xa6' in > > position 1650: ordinal not in

Re: unicode and hashlib

2008-11-29 Thread Jeff H
On Nov 28, 2:03 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Jeff H wrote: > > hashlib.md5 does not appear to like unicode, > >   UnicodeEncodeError: 'ascii' codec can't encode character u'\xa6' in > > position 1650: ordinal not in range(128)

Re: unicode and hashlib

2008-11-29 Thread Jeff H
On Nov 29, 8:27 am, Jeff H <[EMAIL PROTECTED]> wrote: > On Nov 28, 2:03 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > > > > > Jeff H wrote: > > > hashlib.md5 does not appear to like unicode, > > >   UnicodeEncodeError: 'ascii' codec can'

Re: unicode and hashlib

2008-11-29 Thread Jeff H
utf-16 and utf-32 which both have 2 variants and sometimes which one used is based on installed software and/or processors. utf-8 unlike -16/-32 stays reliable and reproducible irrespective of software or hardware. decode vs encode You decode from on character set to a unicode object You encode fro

Re: Generator metadata/attributes

2009-01-07 Thread Jeff McNeil
7;ll have to build your own iterator or wrap the generator object and delegate calls to it. If you elect the latter, you should also ensure that send and throw and gang work properly. Perhaps something nice and thin using getattr within your wrapper class. Jeff On Jan 7, 9:46 pm, acooke@gmail.com

Re: print statements not sent to nohup.out

2008-10-24 Thread Jeff McNeil
On Oct 24, 11:58 am, "John [H2O]" <[EMAIL PROTECTED]> wrote: > Just a quick question.. what do I need to do so that my print statements are > caught by nohup?? > > Yes, I should probably be 'logging'... but hey.. > > Thanks! > -- > View this message in > context:http://www.nabble.com/print-stateme

Re: print statements not sent to nohup.out

2008-10-24 Thread Jeff McNeil
On Oct 24, 11:58 am, "John [H2O]" <[EMAIL PROTECTED]> wrote: > Just a quick question.. what do I need to do so that my print statements are > caught by nohup?? > > Yes, I should probably be 'logging'... but hey.. > > Thanks! > -- > View this message in > context:http://www.nabble.com/print-stateme

Re: subprocess communication, exec()

2008-11-11 Thread Jeff McNeil
if isinstance(args, types.StringTypes): args = [args] else: args = list(args) if shell: args = ["/bin/sh", "-c"] + args So, in your attempt, you're effectively doing the following: /bin/sh -c "python2.5" "server.py" When you want: /bin/sh -c "python2.5 server.py" HTH, Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: return a value to shell script

2008-11-12 Thread Jeff McNeil
echo $? 0 [EMAIL PROTECTED] ~]$ python -c 'import sys; sys.exit(1)' ; echo $? 1 [EMAIL PROTECTED] ~]$ python -c 'import sys; sys.exit(255)' ; echo $? 255 [EMAIL PROTECTED] ~]$ python -c 'import sys; sys.exit(256)' ; echo $? 0 Depending on what you're doing, printing from your Python program and capturing standard out might be a better approach. HTH, Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: Single-instance daemons

2008-11-12 Thread Jeff McNeil
On Nov 12, 4:57 pm, Jeffrey Barish <[EMAIL PROTECTED]> wrote: > As per Stevens/Rago, "file and record locking provides a convenient > mutual-exclusion mechanism". They note the convention of putting the lock > file in /var/run in a file called .pid, where is the name of > the daemon and content i

Re: The return code

2008-11-13 Thread Jeff McNeil
On Nov 13, 4:12 pm, Aaron Brady <[EMAIL PROTECTED]> wrote: > On Nov 13, 6:15 am, "devi thapa" <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I am running one service in the python script eg like > > "service httpd status". > > If I execute this command in normal shell kernel, the return code

Class instantiation fails when passed in a file but work via line by line interpreter

2008-11-18 Thread Jeff Tchang
; subject = SAML.Subject("[EMAIL PROTECTED]","EMailAddress") >>> print subject >>> I've double checked I am loading the correct module by the usage of the -v flag. What else should I be checking? -Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: Class instantiation fails when passed in a file but work via line by line interpreter

2008-11-18 Thread Jeff Tchang
omewhere you've got a > class named SAML that's shadowing your module. See the difference in the > error messages: Thank you! I was being dumb and named by unit test class the same as my actual module. That did it. -Jeff -- http://mail.python.org/mailman/listinfo/python-list

RE: Python + PostgreSQL

2009-03-17 Thread Jeff Peck
dates. The big win for me has been the ease of moving apps between different databases. I have had to do this several times, and the process is mostly painless. Jeff -Original Message- From: python-list-bounces+jpeck=fedex@python.org [mailto:python-list-bounces+jpeck=fedex@pyth

Python 2.6 + Pytz 2009a + Py2exe problem

2009-03-18 Thread Jeff Peck
onger getting compiled to .pyc. Instead, when I check the pytz directory in library.zip, I see these files: __init__.pyc reference.pyc tzfile.pyc tzinfo.pyc It appears that the zoneinfo directory is missing. I have tried pasting this in manually with no luck. Any ideas? Thanks, Jeff Peck -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get the formal args of a function object?

2009-05-14 Thread Jeff McNeil
: return a+b add(1,2) add(1,2,3) $ ./test.py Traceback (most recent call last): File "test.py", line 16, in add(1,2,3) File "test.py", line 5, in wrapper raise Exception("Bad things, Man.") Exception: Bad things, Man. Jeff On May 14, 3:31 pm,

Re: Returning dictionary from a function

2009-05-14 Thread Jeff McNeil
On May 14, 5:44 pm, kk wrote: > Btw my main problem is that when I assign the function to 'b' variable > I only get the last key from the dictionary. Sorry about that I forgot > to mention the main issue. You're creating a new dictionary with each iteration of your loop, use d[k] = v syntax inst

Re: Your Favorite Python Book

2009-05-15 Thread Jeff McNeil
On May 11, 5:45 pm, Chris Rebert wrote: > On Mon, May 11, 2009 at 1:44 PM, Sam Tregar wrote: > > Greetings.  I'm working on learning Python and I'm looking for good books to > > read.  I'm almost done with Dive into Python and I liked it a lot. I found > > Programming Python a little dry the last

Re: Import w/ '.' syntax

2009-05-15 Thread Jeff McNeil
search path somewhere? > Or am I totally misunderstanding the import semantics. > > Thanks, > --Steve In that specific case, you're looking for a module 'bar' in the 'foo' package, which should be located somewhere on sys.path. http://docs.python.org/tutorial/modules.

Re: ? 'in' operator and fallback to __getitem__

2009-05-18 Thread Jeff McNeil
> > Traceback (most recent call last): >   File "", line 1, in >   File "", line 3, in __getitem__ > KeyError: 0 > > I am running on ubuntu, and this happens to 2.5.4 as well.  I must say > I am surprised and > am at a loss as to what is actually going on. > > Can anyone enlighten me (or should I go and read some 'c' code ;-) > > Rgds > > Tim See http://docs.python.org/library/functions.html#iter, that ought to clear it up. Thanks, Jeff mcjeff.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: ? 'in' operator and fallback to __getitem__

2009-05-18 Thread Jeff McNeil
wrote: > > > timh wrote: > > > However strange things happen to the name passed to __getitem__ in the > > > following example (and in fact in all varients I have triend the name/ > > > key passed to __getitem__ is always the integer 0 > > > I think it's scanning the container as a sequence and not as a mapping, > > hence the access by index. > > Whoops, I just realized I posted the wrong link... http://docs.python.org/reference/expressions.html#in Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: How can i use Spread Sheet as Data Store

2009-05-18 Thread Jeff McNeil
;"Odfpy aims to be a > > complete API for OpenDocument in Python. Unlike other more convenient > > APIs, this one is essentially an abstraction layer just above the XML > > format.""" Perhaps much easier than using COM? I didn't see it mentioned yet, but the Google Spreadsheet application is also something you could use if you have a choice. It has a fairly useful API that let's you manage elements. I'm not sure if it's an option for you or not. http://code.google.com/apis/spreadsheets/overview.html Thanks, Jeff mcjeff.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: package with executable

2009-05-19 Thread Jeff McNeil
approach would be to move that code into your gnucal directory, either as it's own module or within one of the existing, and implement it as a "main" function. Then an entry_points line such as the following will make sure 'gnucal' gets installed in a directory on your path: entry_points = { 'console_scripts': [ 'gnucal = gnucal.core:main' ] }, This, of course, assumes that you move your main function into 'gnucal.core.' HTH, Jeff mcjeff.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Passing string from python programs to external programs

2009-05-26 Thread Jeff McNeil
cess >>> sub = subprocess.Popen('/bin/gzip', stdin=subprocess.PIPE, >>> stdout=subprocess.PIPE) >>> g = sub.communicate('Please, sir, gzip me?') >>> import gzip >>> import StringIO >>> gzip.GzipFile(fileobj=StringIO.StringIO(g[0])).read() 'Please, sir, gzip me?' >>> Thanks, Jeff mcjeff.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: download all mib files from a web page

2009-05-27 Thread Jeff McNeil
.. > > $ python > Python 2.4.4 (#1, Oct 23 2006, 13:58:00) > [GCC 4.1.1 20061011 (Red Hat 4.1.1-30)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > > > > My computer is FC6 linux. There's only a couple dozen of them, right-click->Save As. I'm sure Juniper would appreciate that much more than an automated crawler. As far as your ValueError is concerned, consider that 'www.juniper.com' doesn't start with a protocol specification when passed into urllib2.urlopen. -Jeff mcjeff.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: how to change response code in CGIHTTPServer.py

2009-05-29 Thread Jeff McNeil
On May 28, 2:23 pm, Daniel wrote: > Hello, > > Python 2.5.2 > WinXP > > I'm using CGIHTTPServer.py and want to return a response code of 400 > with a message in the event that the cgi script fails for some > reason.  I notice that > run_cgi(self): > executes this line of code, > self.send_response

Re: Unable to write output from os.path.walk to a file.

2008-06-04 Thread Jeff McNeil
name, subdirectories, filenames). It seems that is what you're looking for? Thanks, Jeff On Wed, Jun 4, 2008 at 2:54 PM, Paul Lemelle <[EMAIL PROTECTED]> wrote: > I Am trying to output the os.path.walk to a file, but the writelines method > complains > > Below is

Re: Unable to write output from os.path.walk to a file.

2008-06-04 Thread Jeff McNeil
ar/log')): ... for j in i[1] + i[2]: ... print os.path.join(i[0], j) ... /var/log/apache2 /var/log/cups /var/log/fax /var/log/krb5kdc /var/log/ppp /var/log/sa /var/log/samba On Wed, Jun 4, 2008 at 6:07 PM, Paul Lemelle <[EMAIL PROTECTED]> wrote: > Jeff, > > Thanks fo

os.path.walk -- Can You Limit Directories Returned?

2008-06-04 Thread Jeff Nyman
y directories when what I really want it to do is just grab the directories that are under Sites\ and that's it. I don't want it to recurse down into the sub-directories of the cities. Is there a way to do this? Or is os.path.walk not by best choice here? Any help and/or advice wo

Re: os.path.walk -- Can You Limit Directories Returned?

2008-06-05 Thread Jeff Nyman
Thank you to everyone for your help. Much appreciated. I now have a better understanding of how glob can be used and I have a much better understanding of using the more effective os.walk. - Jeff -- http://mail.python.org/mailman/listinfo/python-list

Creating A Tuple From A List, Adding To Tuple As You Do

2008-06-05 Thread Jeff Nyman
d. I did try this: for count in range(0, len(DC_List)): DC_List.insert(count, '') Here I was thinking I could insert a '' into the right place after each entry in the list. That doesn't quite work. Does anyone have an idea of a good approach here? (I did search on tuples and lists and while I found a lot of information about both, I couldn't find a solution that did what I'm discussing above.) - Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating A Tuple From A List, Adding To Tuple As You Do

2008-06-05 Thread Jeff Nyman
coming up with solutions. Once again, many thanks. - Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: How to send a POST request?

2008-06-06 Thread Jeff McNeil
The original urllib module will do it too, if you pass a data keyword argument to urllib.urlopen: u = urllib.urlopen('http://www.domain.com/cgi-bin/cgi.py', data=urllib.urlencode({'name': 'pythonguy'})) On Fri, Jun 6, 2008 at 6:04 PM, kj <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]> kj <[E

Re: Programming question

2008-06-11 Thread Jeff McNeil
Have a look at os.listdir and os.stat. I've never worked with 1.5, so I don't know what will work with it and what won't,. but I'd imagine the following ought to be fine, though. stat_list = [] for dirent in os.listdir('your_directory'): stat_list.append(os.stat

Re: urllib (54, 'Connection reset by peer') error

2008-06-13 Thread Jeff McNeil
side trying to stop you from running a mass download (especially if it's easily repeatable and happens at about the same byte range). -Jeff On Fri, Jun 13, 2008 at 10:21 AM, <[EMAIL PROTECTED]> wrote: > Hi, > > I have a small Python script to fetch some pages from the in

Re: Making HEAD/PUT/DELETE requests with urllib2?

2008-06-13 Thread Jeff McNeil
The only time I've ever pulled a HEAD request I've used the httplib module directly. Ought to be able to do it like so: Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import h

Re: Socket Programming

2008-06-14 Thread Jeff McNeil
On Jun 14, 5:38 pm, srinivasan srinivas <[EMAIL PROTECTED]> wrote: > Hi, > Is there any way(method) to find whether the socket got closed or not?? > Thanks, > Srini > >       Best Jokes, Best Friends, Best Food and more. Go > tohttp://in.promos.yahoo.com/groups/bestofyahoo/ That's slightly diffi

Re: Looking for lots of words in lots of files

2008-06-18 Thread Jeff McNeil
On Jun 18, 10:29 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > brad wrote: > > Just wondering if anyone has ever solved this efficiently... not looking > > for specific solutions tho... just ideas. > > > I have one thousand words and one thousand files. I need to read the > > files to see if

optparse functionality missing

2008-06-20 Thread Jeff Keasler
o command-line options so that I can pass them to the autoconf command line. Could we get a mode added to optparse so that any commandline parameters/options that are not registered via add_option() can be in the args return value of the parse_args() method? -Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: socket error: connection refused?

2008-06-23 Thread hall . jeff
It's a security conflict. You should be able to run it again and have it work. Our company's cisco does the same thing (even after we approve the app) -- http://mail.python.org/mailman/listinfo/python-list

tuple.index() and tuple.count()

2008-06-23 Thread hall . jeff
Before the inevitable response comes, let me assure you I've read through the posts from Guido about this. 7 years ago Guido clearly expressed a displeasure with allowing these methods for tuple. Let me lay out (in a fresh way) why I think we should reconsider. 1) It's counterintuitive to exclude

Re: tuple.index() and tuple.count()

2008-06-23 Thread hall . jeff
never mind... a coworker pointed me to this http://bugs.python.org/issue1696444 apparently they're there in py3k... -- http://mail.python.org/mailman/listinfo/python-list

Re: Sending information to a website

2008-06-24 Thread Jeff McNeil
On Jun 24, 12:13 am, Alex Bryan <[EMAIL PROTECTED]> wrote: > Okay, so what I want to do is connect to dictionary.com and send the > website a word, and later receive the definition. But for now, I want > to focus on sending the word. A good guy from this mailing list said I > should look into the c

Re: using urllib2

2008-06-27 Thread Jeff McNeil
I stumbled across this a while back: http://www.voidspace.org.uk/python/articles/urllib2.shtml. It covers quite a bit. The urllib2 module is pretty straightforward once you've used it a few times. Some of the class naming and whatnot takes a bit of getting used to (I found that to be the most con

Re: using urllib2

2008-06-29 Thread Jeff McNeil
thing. But I want to know why you put "for tabs," also why you > need the "'table', {'class': 'luna-Ent'}):" Like why the curly braces and > whatnot? > > Jeff McNeil-2 wrote: > > > On Jun 27, 10:26 pm, Alexnb <[EMAIL PROTECTE

Re: using urllib2

2008-06-29 Thread Jeff McNeil
give you a few pointers -- not provide production quality code. If you need definitions, another place you may want to look would be google's JSON search API. You may be able to search for 'define:word', and then you don't have to rely on the screen scraping. Thanks! Jeff On Jun 29

imported module no longer available

2008-07-21 Thread Jeff Dyke
acing import mymodulename again in this method, but can't have that everywhere. I will try to come up with a generic reproduction of this issue, but that might take some time. I've also seen this in the past with the python builtin 'sys' I did see a bug http://bugs.python.org/issue2378, which has very similar behaviour, but is different. Python 2.5, ubuntu hardy Thanks for any insight, Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: imported module no longer available

2008-07-21 Thread Jeff Dyke
my apologies, to Fredrick, my response when solely to him. reply below, hopefully keeping thread intact. On Mon, Jul 21, 2008 at 12:28 PM, Jeff Dyke <[EMAIL PROTECTED]> wrote: > On Mon, Jul 21, 2008 at 10:19 AM, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >> Jeff Dyke wrote: &g

Preferred method for "Assignment by value"

2008-04-15 Thread hall . jeff
As a relative new comer to Python, I haven't done a heck of a lot of hacking around with it. I had my first run in with Python's quirky (to me at least) tendency to assign by reference rather than by value (I'm coming from a VBA world so that's the terminology I'm using). I was surprised that these

Re: Preferred method for "Assignment by value"

2008-04-15 Thread hall . jeff
Thank you both, the assigning using slicing works perfectly (as I'm sure you knew it would)... It just didn't occur to me because it seemed a little nonintuitive... The specific application was def dicttolist (inputdict): finallist=[] for k, v in inputdict.iteritems(): temp = v

<    5   6   7   8   9   10   11   >