Re: Can someone tell me why i get None at the end please this has me stuck for ages

2009-02-23 Thread Albert Hopkins
On Mon, 2009-02-23 at 19:22 +, Gary Wood wrote: '''exercise to complete and test this function''' import string def joinStrings(items): '''Join all the strings in stringList into one string, and return the result. For example: print joinStrings(['very', 'hot', 'day'])

Re: Is there any equivalent feature available in Python..?

2009-02-24 Thread Albert Hopkins
On Tue, 2009-02-24 at 11:05 -0800, zaheer.ag...@gmail.com wrote: Hi, Is there any Python equivalent of java jar,can I include all my sources,properties file etc into a single file.Is there anyway in Python that I can run like the following java -jar Mytest.jar --startwebserver How to

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(x)

Re: Can someone explain this behavior to me?

2009-02-26 Thread Albert Hopkins
On Thu, 2009-02-26 at 13:48 -0800, Jesse Aldridge wrote: I have one module called foo.py - class Foo: foo = None def get_foo(): return Foo.foo if __name__ == __main__: import bar Foo.foo = foo bar.go() - And another one

Re: Wanting to fire an event when property content changes

2009-03-03 Thread Albert Hopkins
On Tue, 2009-03-03 at 13:41 -0600, nuwandame wrote: What I am wanting to do is execute code whenever a property of a class object has been changed. i.e. class test: testproperty = None bob = test() bob.testproperty = 'something' So, when bob.testproperty is set to a new

Re: /a is not /a ?

2009-03-07 Thread Albert Hopkins
On Fri, 2009-03-06 at 23:57 -0800, Paul Rubin wrote: alex23 wuwe...@gmail.com writes: But _you_ only _just_ stated It does have some (generally small) performance ramifications as well and provided timing examples to show it. Without qualification. The performance difference can be large

Re: /a is not /a ?

2009-03-07 Thread Albert Hopkins
On Sat, 2009-03-07 at 03:07 -0500, Albert Hopkins wrote: On Fri, 2009-03-06 at 23:57 -0800, Paul Rubin wrote: alex23 wuwe...@gmail.com writes: But _you_ only _just_ stated It does have some (generally small) performance ramifications as well and provided timing examples to show

Re: Raw String Question

2009-03-12 Thread Albert Hopkins
Yep...as documented[1], even a raw string cannot end in an odd number of backslashes. So how do you explain this? r'a\'b' a\\'b That doesn't end in an odd number of backslashes. Python is __repr__esenting a raw string as a regular string. Literally they are equivalent:

Re: unbiased benchmark

2009-03-12 Thread Albert Hopkins
On Thu, 2009-03-12 at 13:25 -0700, Chris Rebert wrote: On Thu, Mar 12, 2009 at 1:07 PM, Sam Ettessoc sami...@gmail.com wrote: I would like to share a benchmark I did. The computer used was a 2160MHz Intel Core Duo w/ 2000MB of 667MHz DDR2 SDRAM running MAC OS 10.5.6 and a lots of software

Re: Getting final url when original url redirects

2009-03-12 Thread Albert Hopkins
On Thu, 2009-03-12 at 12:57 -0700, IanR wrote: I'm processing RSS content from a # of given sources. Most of the time the url given by the RSS feed redirects to the real URL (I'm guessing they do this for tracking purposes) For example. This is a url that I get from and RSS feed,

Re: How to find in in the documentation

2009-03-13 Thread Albert Hopkins
On Fri, 2009-03-13 at 21:01 +, tinn...@isbd.co.uk wrote: I've had this trouble before, how do I find the details of how in works in the documentation. E.g. the details of:- if string in bigstring: It gets a mention in the if section but not a lot. From

Re: Neatest way to do a case insensitive in?

2009-03-13 Thread Albert Hopkins
On Fri, 2009-03-13 at 21:04 +, tinn...@isbd.co.uk wrote: What's the neatest way to do the following in case insensitive fashion:- if stringA in stringB: bla bla bla I know I can just do:- if stringA.lower() in stringB.lower(): bla bla bla But I was

Re: Tuple passed to function recognised as string

2009-03-18 Thread Albert Hopkins
On Wed, 2009-03-18 at 16:58 -0700, Mike314 wrote: Hello, I have following code: def test_func(val): print type(val) test_func(val=('val1')) test_func(val=('val1', 'val2')) The output is quite different: type 'str' type 'tuple' Why I have string in the first case? You

Re: Can I rely on...

2009-03-19 Thread Albert Hopkins
On Thu, 2009-03-19 at 08:42 -0700, Emanuele D'Arrigo wrote: Hi everybody, I just had a bit of a shiver for something I'm doing often in my code but that might be based on a wrong assumption on my part. Take the following code: pattern = aPattern compiledPatterns = [ ]

Re: Missing values in tuple assignment

2009-03-19 Thread Albert Hopkins
On Thu, 2009-03-19 at 11:57 -0500, Jim Garrison wrote: Use case: parsing a simple config file line where lines start with a keyword and have optional arguments. I want to extract the keyword and then pass the rest of the line to a function to process it. An obvious use of split(None,1)

Re: Neatest way to do a case insensitive in?

2009-03-19 Thread Albert Hopkins
On Fri, 2009-03-20 at 07:25 +1100, Jervis Whitley wrote: if stringA.lower() in stringB.lower(): bla bla bla from string import lower if lower(stringA) in lower(stringB): # was this what you were after? This is analogous to standing behind a perfectly

Re: Neatest way to do a case insensitive in?

2009-03-19 Thread Albert Hopkins
On Fri, 2009-03-20 at 08:52 +1100, Jervis Whitley wrote: On Fri, Mar 20, 2009 at 8:28 AM, Albert Hopkins mar...@letterboxes.org wrote: On Fri, 2009-03-20 at 07:25 +1100, Jervis Whitley wrote: if stringA.lower() in stringB.lower(): bla bla bla from string import

Re: get rid of duplicate elements in list without set

2009-03-20 Thread Albert Hopkins
On Fri, 2009-03-20 at 07:16 -0700, Alexzive wrote: Hello there, I'd like to get the same result of set() but getting an indexable object. How to get this in an efficient way? Example using set A = [1, 2, 2 ,2 , 3 ,4] B= set(A) B = ([1, 2, 3, 4]) B[2] TypeError: unindexable

Re: meta question - how to read comp.lang.python w/o usenet feed/google interface?

2009-03-20 Thread Albert Hopkins
On Fri, 2009-03-20 at 07:42 -0700, Esmail wrote: Hi all, I've been reading/posting to usenet since the 80s with a variety of tools (vn, and most recently Thunderbird) but since my ISP (TimeWarner) no longer provides usenet feeds I'm stuck. I am not crazy about the web interface via google

Re: get rid of duplicate elements in list without set

2009-03-20 Thread Albert Hopkins
On Fri, 2009-03-20 at 07:54 -0700, thomasvang...@gmail.com wrote: You could use: B=list(set(A)).sort() Hope that helps. Which will assign None to B. sorted(list(... or B.sort() is probably what you meant. -- http://mail.python.org/mailman/listinfo/python-list

Re: py2exe linux equivalent

2009-03-20 Thread Albert Hopkins
On Fri, 2009-03-20 at 12:59 -0700, Brendan Miller wrote: I have a python application that I want to package up and deploy to various people using RHEL 4. I'm using python 2.6 to develop the app. The RHEL 4 machines have an older version of python I'd rather not code against (although that's

Re: A problem with subprocess

2009-03-20 Thread Albert Hopkins
On Fri, 2009-03-20 at 22:14 -0400, Colin J. Williams wrote: Below is a test script: # tSubProcess.py import subprocess import sys try: v= subprocess.Popen('ftype py=C:\Python25\Python.exe') except WindowsError: print(sys.exc_info()) Here is the output: *** Python 2.5.4

Re: __init__ vs. __del__

2009-03-21 Thread Albert Hopkins
On Sat, 2009-03-21 at 17:41 -0700, Randy Turner wrote: Hi, I was reading a book on Python-3 programming recently and the book stated that, while there is an __init__ method for initializing objects, there was a __del__ method but the __del__ method is not guaranteed to be called when an

Re: 3.0 - bsddb removed

2009-03-22 Thread Albert Hopkins
On Sun, 2009-03-22 at 15:55 +, Sean wrote: Anyone got any thoughts about what to use as a replacement. I need something (like bsddb) which uses dictionary syntax to read and write an underlying (fast!) btree or similar. gdbm -- http://mail.python.org/mailman/listinfo/python-list

Re: Another form of dynamic import

2009-03-25 Thread Albert Hopkins
Also, instead of caching exceptions you can do lazy lookups kinda like this: - # a.py class A: pass - # b.py class B:

Re: What way is the best to check an empty list?

2009-03-25 Thread Albert Hopkins
On Wed, 2009-03-25 at 21:26 +, Martin P. Hellwig wrote: PEP 8 recommends the latter. Raymond I can't seem to find where this recommendation is mentioned or implied. Wow, you must not have looked very hard: 1. Point your browser to http://www.python.org/dev/peps/pep-0008/

Re: Odd behavior regarding a list

2009-03-26 Thread Albert Hopkins
On Thu, 2009-03-26 at 08:36 -0700, Edd Barrett wrote: Hi there, My first post here, so hello :) Just a little background, I am writing my dissertation, which is a JIT compiler based upon LLVM and it's python bindings, along with the aperiot LL(1) parser. I have some code here, which is

Re: Find duplicates in a list and count them ...

2009-03-26 Thread Albert Hopkins
On Thu, 2009-03-26 at 12:22 -0700, paul.scipi...@aps.com wrote: Hello, I'm a newbie to Python. I have a list which contains integers (about 80,000). I want to find a quick way to get the numbers that occur in the list more than once, and how many times that number is duplicated in the

Re: Find duplicates in a list and count them ...

2009-03-26 Thread Albert Hopkins
On Thu, 2009-03-26 at 15:54 -0400, Albert Hopkins wrote: [...] $ cat test.py from random import randint l = list() for i in xrange(8): l.append(randint(0,10)) ^^^ should have been: l.append(randint(0,9)) hist = dict() for i in l: hist[i

Re: running shelscript inside python

2009-03-26 Thread Albert Hopkins
On Thu, 2009-03-26 at 15:23 -0700, harijay wrote: Hi I want to run shell scripts of the following kind from inside python and for some reason either the os.system or the subprocess.call ways are not working for me . I am calling a fortran command (f2mtz ) with some keyworded input that is

Re: c.l.py dead, news at 11 (was Re: Mangle function name with decorator?)

2009-03-27 Thread Albert Hopkins
On Fri, 2009-03-27 at 10:47 -0700, Aahz wrote: In article mailman.2787.1238174158.11746.python-l...@python.org, andrew cooke and...@acooke.org wrote: Aahz wrote: Excuse me? What decline of this newsgroup? Hmmm. It's hard to respond to this without implicitly criticising others here,

Re: pyqt drop to open a file

2009-03-27 Thread Albert Hopkins
On Fri, 2009-03-27 at 17:55 -0700, rui.li.s...@gmail.com wrote: Hi, anyone can give a simple example or a link on how to use 'drop' with pyqt. what I'm looking for is drop a file to main widget then program get the path\filename something like: main_widget set to accept 'drop event',

Re: c.l.py dead, news at 11 (was Re: Mangle function name with decorator?)

2009-03-27 Thread Albert Hopkins
On Fri, 2009-03-27 at 21:15 -0400, andrew cooke wrote: [...] c.l.python used to be the core of a community built around a language. It no longer is. It is a very useful place, where some very helpful and knowledgeable people hang out and give advice, but instead of representing the full

Re: Psycopg Documentation

2009-03-29 Thread Albert Hopkins
On Sun, 2009-03-29 at 11:35 +0100, taliesin wrote: Hi, I'm probably being very dense so apologies in advance, but I can't find any decent documentation for the psycopg module for PostgreSQL interfacing. Google and Yahoo don't seem to return much for any of the queries I gave them and

Re: Did you noticed that Unipath is not more available?

2009-03-29 Thread Albert Hopkins
On Sun, 2009-03-29 at 15:17 +0200, Andrea Francia wrote: Do you know/use Unipath? Unipath is a OO path manipulation library. It's used, for example, to rename, copy, deleting files. Unfortunately this library is no more available as I reported in [1]. I found a copy of the .egg in a my

Re: Problems with code

2009-03-30 Thread Albert Hopkins
On Mon, 2009-03-30 at 11:05 -0500, Zach Goscha wrote: Hi, I am trying to call an unbound method (Map.Background) but getting the following error: TypeError: unbound method background() must be called with Map instance as first argument (got nothing instead) Here is some of the

Re: imp.load_source() - explanation needed

2009-04-01 Thread Albert Hopkins
On Wed, 2009-04-01 at 12:17 -0700, mynthon wrote: Hi! I need help. I don't understand what doc says. I load module from path testmod/mytest.py using imp.load_source(). My code is import imp testmod = imp.load_source('koko', 'testmod/mytest.py) print testmod but i don't understand

Re: statvfs clearance

2009-04-04 Thread Albert Hopkins
On Sat, 2009-04-04 at 03:56 -0700, Sreejith K wrote: Python's statvfs module contains the following indexes to use with os.statvfs() that contains the specified information statvfs.F_BSIZE Preferred file system block size. statvfs.F_FRSIZE Fundamental file system block size.

Re: statvfs clearance

2009-04-04 Thread Albert Hopkins
On Sat, 2009-04-04 at 15:48 +0200, Hrvoje Niksic wrote: Sreejith K sreejith...@gmail.com writes: Python's statvfs module contains the following indexes to use with os.statvfs() that contains the specified information statvfs.F_BSIZE Preferred file system block size. [...]

Re: Issue with subprocess Module

2009-04-07 Thread Albert Hopkins
On Tue, 2009-04-07 at 07:53 -0400, Dave Angel wrote: subprocess.Popen() is expecting the name of a program, which should normally have an extension of .exe You're handing it a .bat file, which is not executable. It only executes in the context of a command interpreter (shell), such

Re: Why does Python show the whole array?

2009-04-08 Thread Albert Hopkins
On Wed, 2009-04-08 at 12:01 +0200, Peter Otten wrote: Gilles Ganault wrote: I'd like to go through a list of e-mail addresses, and extract those that belong to well-known ISP's. For some reason I can't figure out, Python shows the whole list instead of just e-mails that match:

Re: Computed attribute names

2009-04-08 Thread Albert Hopkins
On Wed, 2009-04-08 at 19:47 +0100, Dale Amon wrote: There are a number of things which I have been used to doing in other OO languages which I have not yet figured out how to do in Python, the most important of which is passing method names as args and inserting them into method calls. Here

Re: Decompression with zlib

2009-04-08 Thread Albert Hopkins
On Wed, 2009-04-08 at 23:51 +0200, Emma Li wrote: Hello, I'm trying to do compression/decompression of stuff with zlib, and I just don't get it... Here is an example. I assume that dec should be a, but it isn't. dec turns out to be an empty string, and I don't understand why...

Re: any(), all() and empty iterable

2009-04-11 Thread Albert Hopkins
On Sun, 2009-04-12 at 04:00 +, John O'Hagan wrote: Hi, I was getting some surprising false positives as a result of not expecting this: all(element in item for item in iterable) to return True when 'iterable' is empty. I guess it goes into hairy Boolean territory trying to

When is min(a, b) != min(b, a)?

2008-01-20 Thread Albert Hopkins
This issue may have been referred to in news:[EMAIL PROTECTED] but I didn't entirely understand the explanation. Basically I have this: a = float(6) b = float('nan') min(a, b) 6.0 min(b, a) nan max(a, b) 6.0 max(b, a) nan Before I did not know

Re: When is min(a, b) != min(b, a)?

2008-01-20 Thread Albert Hopkins
On Sun, 20 Jan 2008 20:16:18 -0800, Paddy wrote: I am definitely NOT a floating point expert, but I did find this: http://en.wikipedia.org/wiki/IEEE_754r#min_and_max P.S. What platform /Compiler are you using for Python? Linux with GCC 4 -a --

Re: parsing grub's menu.lst

2008-11-17 Thread Albert Hopkins
On Mon, 2008-11-17 at 10:27 -0800, CarlFK wrote: I need some code that will read in grubs menu.lst file, and give me a list of dicts: [{'title':'Ubuntu, kernel 2.6.15-23-686', 'root':'(hd0,0)', 'kernel':'/boot/vmlinuz-2.6.15-23-686 root=/dev/hda1 ro quiet splash',

Re: Retrieve Custom 404 page.

2008-11-17 Thread Albert Hopkins
On Mon, 2008-11-17 at 13:59 -0800, godavemon wrote: I'm using urllib2 to pull pages for a custom version of a web proxy and am having issues with 404 errors. Urllib2 does a great job of letting me know that a 404 happened with the following code. import urllib2 url =

Re: subprocess with shared environment?

2008-11-17 Thread Albert Hopkins
On Mon, 2008-11-17 at 15:27 -0800, rowen wrote: I'd like to replace some shell scripts with Python, but one step of the script modifies my environment in a way that the subsequent steps require. A simple translation to a few lines of subprocess.call(...) fails because the first call

Re: setting permissions to a file from linux.

2008-11-18 Thread Albert Hopkins
On Tue, 2008-11-18 at 04:36 -0800, gaurav kashyap wrote: Hi all, I have a text file in a directory on unix system. Using a python program i want to change that file's permissions. How could this be done. Thanks os.chmod = chmod(...) chmod(path, mode) Change the access

Re: Python Script to search by Date

2008-11-25 Thread Albert Hopkins
On Tue, 2008-11-25 at 16:10 -0800, [EMAIL PROTECTED] wrote: What I'm trying to do is decompress a bunch of files depending on the date/time specified. So, we have full backups created every Sunday and transaction backups every hour afterwards. I have everything compressed at an hourly

Re: newbie question

2008-11-26 Thread Albert Hopkins
On Wed, 2008-11-26 at 11:11 -0800, Nan wrote: Hello, I just started to use Python. I wrote the following code and expected 'main' would be called. def main(): print hello main But I was wrong. I have to use 'main()' to invoke main. The python interpreter does not give any

Re: Version upgrade blocked mentally

2008-11-29 Thread Albert Hopkins
On Sat, 2008-11-29 at 12:32 -0800, Adam E wrote: I have read in my copy of Programming Python that all strings will be Unicode and there will be a byte type. This is mentally keeping me from upgrading to 2.6 . Care to explain? Actually what you describe is a change change takes place in

Re: Convert hexadecimal characters to ascii

2008-11-29 Thread Albert Hopkins
On Sat, 2008-11-29 at 20:39 +, Durand wrote: Hi, I've got this weird problem where in some strings, parts of the string are in hexadecimal, or thats what I think they are. I'm not exactly sure...I get something like this: 's\x08 \x08Test!' from parsing a log file. From what I found

Re: Emacs vs. Eclipse vs. Vim

2008-11-29 Thread Albert Hopkins
On Sun, 2008-11-30 at 02:18 +0100, Stef Mientki wrote: First, you must understand that this is an extremelly dangerous question to ask on a public newsgroup (expecially regarding the first and the third in the series). Wars have began over this. Many people were harmed in those wars. Many

Re: Obama's Birth Certificate - Demand that US presidential electors investigate Obama's eligibility

2008-12-03 Thread Albert Hopkins
This has nothing to do with Python. Please take this thread to cares.who.someone. -- http://mail.python.org/mailman/listinfo/python-list

Re: as keyword woes

2008-12-03 Thread Albert Hopkins
On Wed, 2008-12-03 at 13:38 -0800, Warren DeLano wrote: A bottom line / pragmatic question... hopefully not a FAQ. Why was it necessary to make as a reserved keyword? And more to the point, why was it necessary to prevent developers from being able to refer to attributes named as?

Re: Python 3 read() function

2008-12-04 Thread Albert Hopkins
On Thu, 2008-12-04 at 20:01 +0100, Дамјан Георгиевски wrote: I don't think it matters. Here's a quick comparison between 2.5 and 3.0 on a relatively small 17 meg file: C:\c:\Python30\python -m timeit -n 1 open('C:\\work\\temp\\bppd_vsub.csv', 'rb').read() 1 loops, best of 3: 36.8 sec

Re: as keyword woes

2008-12-04 Thread Albert Hopkins
It's been a while so I can't remember, but it seems like yield was dropped in to python relatively quickly in 2.2. Was there a similar outrage when yield became a keyword? -a -- http://mail.python.org/mailman/listinfo/python-list

Re: Insert Multiple Records Using One Insert Statemen with MySQLdb module

2008-12-06 Thread Albert Hopkins
On Sat, 2008-12-06 at 04:03 -0800, [EMAIL PROTECTED] wrote: Hi, I'd like to insert Multiple Records Using One Insert Statement inserting one record using one insert statement works this is the example: import MySQLdb conn = MySQLdb.connect(host=localhost,.) cursore = conn.cursor()

When (and why) to use del?

2008-12-09 Thread Albert Hopkins
I'm looking at a person's code and I see a lot of stuff like this: def myfunction(): # do some stuff stuff my_string = function_that_returns_string() # do some stuff with my_string del my_string # do some other stuff

Can't figure out where SyntaxError: can not delete variable 'x' referenced in nested scope us coming from in python =2.6

2008-12-09 Thread Albert Hopkins
Say I have module foo.py: def a(x): def b(): x del x If I run foo.py under Python 2.4.4 I get: File foo.py, line 4 del x SyntaxError: can not delete variable 'x' referenced in nested scope Under Python

Re: Is 3.0 worth breaking backward compatibility?

2008-12-09 Thread Albert Hopkins
On Tue, 2008-12-09 at 20:56 +, Lie Ryan wrote: Actually I noticed a tendency from open-source projects to have slow increment of version number, while proprietary projects usually have big version numbers. Linux 2.x: 1991 Python 3.x.x: 1991. Apache 2.0: 1995. OpenOffice.org 3.0:

Re: Can't figure out where SyntaxError: can not delete variable 'x' referenced in nested scope us coming from in python =2.6

2008-12-09 Thread Albert Hopkins
On Tue, 2008-12-09 at 22:57 +, Steven D'Aprano wrote: [...] So is there a way to find the offending code w/o having to go through every line of code in 'foo' by hand? Just search for del x in your code. Your editor does have a search function, surely? Well, you'd think I'd be

Re: How to read stdout from subprocess as it is being produced

2008-12-19 Thread Albert Hopkins
On Fri, 2008-12-19 at 06:34 -0800, Alex wrote: Hi, I have a Pyhon GUI application that launches subprocess. I would like to read the subprocess' stdout as it is being produced (show it in GUI), without hanging the GUI. I guess threading will solve the no-hanging issue, but as far as I

Re: print to console without a line break

2008-12-23 Thread Albert Hopkins
On Tue, 2008-12-23 at 13:18 +, Lie Ryan wrote: On Tue, 23 Dec 2008 11:50:59 +0100, Qian Xu wrote: Hello All, Is it possible to print something to console without a line break? I tried: sys.stdout.write(Testing something ...) // nothing will be printed time.sleep(1)

Re: need help with list/variables

2008-12-30 Thread Albert Hopkins
On Tue, 2008-12-30 at 11:31 -0800, wx1...@gmail.com wrote: I have a list and would like to parse the list appending each list item to the end of a variable on a new line. for instance mylist = ['something\n', 'another something\n', 'something again\n'] then parse mylist to make it

Re: parse/slice/...

2009-01-06 Thread Albert Hopkins
On Tue, 2009-01-06 at 11:23 -0800, rcmn wrote: I'm not sure how to call it sorry for the subject description. Here what i'm trying to accomplish. the script i'm working on, take a submitted list (for line in file) and generate thread for it. unfortunately winxp has a limit of 500 thread .

Re: How do you write to the printer ?

2009-01-08 Thread Albert Hopkins
On Wed, 2009-01-07 at 16:46 -0600, da...@bag.python.org wrote: Can find nothing in the on-line docs or a book. Groping in the dark I attempted : script24 import io io.open('stdprn','w') # accepted stdprn.write('hello printer') # fails stdprn is not defined You

Re: Looking for an efficient Python script to download and save a .zip file programmatically

2009-01-10 Thread Albert Hopkins
On Sat, 2009-01-10 at 17:12 +, David Shi wrote: I am looking for an efficient Python script to download and save a .zip file programmatically (from http or https call). Regards. David urllib? -a -- http://mail.python.org/mailman/listinfo/python-list

Re: trying to modify locals() dictionary

2009-01-12 Thread Albert Hopkins
On Mon, 2009-01-12 at 19:51 +0100, TP wrote: Hi everybody, I try to modify locals() as an exercise. According to the context (function or __main__), it works differently (see below). Why? Thanks Julien Per the locals() documentation @ http://docs.python.org/library/functions.html

Re: exec in a nested function yields an error

2009-01-13 Thread Albert Hopkins
On Tue, 2009-01-13 at 16:13 +0100, TP wrote: Hi everybody, Try the following program: def f(): def f_nested(): exec a=2 print a f() It yields an error. $ python nested_exec.py File nested_exec.py, line 3 exec

Re: basic python list/dict/key question/issues..

2009-01-13 Thread Albert Hopkins
On Tue, 2009-01-13 at 08:59 -0800, bruce wrote: Hi.. quite new to python, and have a couple of basic question: i have (term:[1,2,3]) as i understand it, this is a list, yes/no? No, that's invalid syntax: (term:[1,2,3]) File stdin, line 1

Re: Read binary file and dump data in

2009-01-13 Thread Albert Hopkins
On Tue, 2009-01-13 at 12:02 -0800, Santiago Romero wrote: Hi. Until now, all my python programs worked with text files. But now I'm porting an small old C program I wrote lot of years ago to python and I'm having problems with datatypes (I think). some C code: fp = fopen( file, rb);

Re: pep 8 constants

2009-01-14 Thread Albert Hopkins
On Wed, 2009-01-14 at 16:58 +1000, James Mills wrote: [...] Still I would avoid using this idiom altogether and jsut stick with default values. For Example: FOO = 1 def f(x=FOO): ... Use this instead: def f(x=1): ... That only works well when 1 is only used once, and as an

Re: Kill a function while it's being executed

2009-02-04 Thread Albert Hopkins
On Wed, 2009-02-04 at 13:40 +0200, Noam Aigerman wrote: Hi All, I have a script in which I receive a list of functions. I iterate over the list and run each function. This functions are created by some other user who is using the lib I wrote. Now, there are some cases in which the function I

Re: where clause

2009-02-05 Thread Albert Hopkins
On Thu, 2009-02-05 at 10:04 -0800, bearophileh...@lycos.com wrote: This comes after a small discussion in another Python newsgroup. Haskell supports a where clause, that's syntactic sugar that allows you to define things like this: p = a / b where a = 20 / len(c) b = foo(d)

Re: Is c.l.py becoming less friendly?

2009-02-06 Thread Albert Hopkins
Probably that [c.l.]python is becoming more popular and, like most things as they become popular, it loses its purity... much like the Internet in the early 1990s. -- http://mail.python.org/mailman/listinfo/python-list

Re: isfifo?

2009-02-07 Thread Albert Hopkins
On Sat, 2009-02-07 at 17:12 +, rdmur...@bitdance.com wrote: I've googled and looked through os.path, but I don't see a method for determining if a path points to a FIFO. Anyone know of a simple way to do so? import os import stat st_mode = os.stat(path)[0] isfifo = stat.S_ISFIFO(st_mode)

Re: bool evaluations of generators vs lists

2009-02-10 Thread Albert Hopkins
On Tue, 2009-02-10 at 11:15 -0800, Josh Dukes wrote: quite simply...what??? In [108]: bool([ x for x in range(10) if False ]) Out[108]: False In [109]: bool( x for x in range(10) if False ) Out[109]: True Why do these two evaluate differently? I was expecting that they would evaluate

Re: bool evaluations of generators vs lists

2009-02-10 Thread Albert Hopkins
On Tue, 2009-02-10 at 12:50 -0800, Josh Dukes wrote: The thing I don't understand is why a generator that has no iterable values is different from an empty list. Why shouldn't bool == has_value?? Technically a list, a tuple, and a string are also objects but if they lack values they're

Re: Unicode issue on Windows cmd line

2009-02-11 Thread Albert Hopkins
On Wed, 2009-02-11 at 10:35 -0800, jeffg wrote: Having issue on Windows cmd. Python.exe a = u'\xf0' print a This gives a unicode error. Works fine in IDLE, PythonWin, and my Macbook but I need to run this from a windows batch. Character should look like this ð. Please help! You

Re: Function name limit in Python ?

2009-02-14 Thread Albert Hopkins
On Sat, 2009-02-14 at 07:45 -0700, Linuxguy123 wrote: Excuse my ignorance, but is there a limit to the size of function names in Python ? I named a function getSynclientVersion() and I got an error when I called it. You forgot to paste the error. --

Re: listing files by modification time

2009-02-17 Thread Albert Hopkins
On Tue, 2009-02-17 at 19:46 +0530, Deepak Rokade wrote: Yes I can do that but for that I will have to go through entire list of files and also I will have to first get the whole list of files present in directory. In case of my application this list can be huge and so want to list the

Re: Regular expression bug?

2009-02-19 Thread Albert Hopkins
On Thu, 2009-02-19 at 10:55 -0800, Ron Garret wrote: I'm trying to split a CamelCase string into its constituent components. This kind of works: re.split('[a-z][A-Z]', 'fooBarBaz') ['fo', 'a', 'az'] but it consumes the boundary characters. To fix this I tried using lookahead and

Re: Forwarding keyword arguments from one function to another

2009-02-22 Thread Albert Hopkins
On Sun, 2009-02-22 at 11:44 -0800, Ravi wrote: The following code didn't work: class X(object): def f(self, **kwds): print kwds try: print kwds['i'] * 2 except KeyError: print unknown

Re: Forwarding keyword arguments from one function to another

2009-02-22 Thread Albert Hopkins
On Sun, 2009-02-22 at 12:09 -0800, Ravi wrote: I am sorry about the typo mistake, well the code snippets are as: # Non Working: class X(object): def f(self, **kwds): print kwds try: print kwds['i'] * 2 except KeyError: print unknown keyword argument self.g(string,

Re: pickle.load() on an dictionary of dictionaries doesn't load full data structure on first call

2009-02-22 Thread Albert Hopkins
On Sun, 2009-02-22 at 16:15 -0800, James Pearson wrote: I've been using irclib to write a simple irc bot, and I was running into some difficulties with pickle. Upon some experimentation with pdb, I found that pickle.load() doesn't load *all* of the data the _first_ time it's called. For

Re: Web development with Python 3.1

2009-10-28 Thread Albert Hopkins
On Wed, 2009-10-28 at 15:32 +0200, Dotan Cohen wrote: def index(request): unmaintanable_html = html head titleIndex/title /head body h1Embedded HTML is a PITA/h1 pbut some like pains.../p /body /html return HttpResponse(unmaintanable_html) And if

Re: Web development with Python 3.1

2009-10-28 Thread Albert Hopkins
On Wed, 2009-10-28 at 16:38 +0200, Dotan Cohen wrote: return HttpResponse(unmaintanable_html % data) That's fine for single variables, but if I need to output a table of unknown rows? I assume that return means the end of the script. Therefore I should shove the whole table into a

Re: popen function of os and subprocess modules

2009-10-28 Thread Albert Hopkins
On Wed, 2009-10-28 at 07:15 -0700, banu wrote: Thanks for the reply Jon Basically I need to move into a folder and then need to execute some shell commands(make etc.) in that folder. I just gave 'ls' for the sake of an example. The real problem I am facing is, how to stay in the folder

Re: Aaaargh! global name 'eggz' is not defined

2009-10-29 Thread Albert Hopkins
On Thu, 2009-10-29 at 17:27 -0500, Robert Kern wrote: I consider import * the first error to be fixed, so it doesn't bother me much. :-) But does pyflakes at least *warn* about the use of import * (I've never used it so just asking)? -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: DARPA red balloon challenge

2009-10-30 Thread Albert Hopkins
On Thu, 2009-10-29 at 20:27 -0700, Adam N wrote: [...] On December 5, DARPA will raise 10 red weather balloons somewhere in the US. The first person to get the location of all 10 balloons and submit them will be given $40k. Hasn't the U.S. had enough weather balloon-related publicity stunts?

Re: Are *.pyd's universal?

2009-10-31 Thread Albert Hopkins
On Sat, 2009-10-31 at 21:32 +1300, Lawrence D'Oliveiro wrote: Modules will sometimes find themselves on the path in Windows, so the fact that Windows performs a library search on the path is quite significant. Why is it only Windows is prone to this problem? I think as someone pointed

Re: datetime question

2009-10-31 Thread Albert Hopkins
On Sat, 2009-10-31 at 10:08 +1100, Ben Finney wrote: The ‘datetime’ module focusses on individual date+time values (and the periods between them, with the ‘timedelta’ type). For querying the properties of the calendar, use the ‘calendar’ module. Yes, it would be nice if the ‘time’,

Re: datetime question

2009-10-31 Thread Albert Hopkins
On Sat, 2009-10-31 at 20:34 +1100, Ben Finney wrote: Fixing ‘time’, ‘datetime’, and ‘calendar’ was the reason for Python 3? No, it wasn't. Or perhaps you mean that any backward-incompatible change was a reason to have Python 3? Even more firmly no. The extent of changes was severely limited

Re: Python 2.6.4: ./configure does not work

2009-10-31 Thread Albert Hopkins
On Sat, 2009-10-31 at 03:07 -0700, knipknap wrote: Hi, Running ./configure in the 2.6.4 sources produces the following error: config.status: error: cannot find input file: Makefile.pre.in Indeed, such a file is not contained anywhere in the Pakage. Which sources are you referring to?

Re: Are *.pyd's universal?

2009-10-31 Thread Albert Hopkins
On Sat, 2009-10-31 at 23:58 +1300, Lawrence D'Oliveiro wrote: I just checked my Debian installation: l...@theon:~ find /lib /usr/lib -name \*.so -a -not -name lib\* -print | wc -l 2950 l...@theon:~ find /lib /usr/lib -name \*.so -print | wc -l 4708 So 63% of the

Re: import bug

2009-10-31 Thread Albert Hopkins
On Sat, 2009-10-31 at 16:27 +, kj wrote: 2) this has been fixed in Py3 In my post I illustrated that the failure occurs both with Python 2.6 *and* Python 3.0. Did you have a particular version of Python 3 in mind? I was not able to reproduce with my python3: $ head ham/*.py

Re: Detecting new removable drives in Linux

2010-03-01 Thread Albert Hopkins
On Mon, 2010-03-01 at 10:48 +0100, Bart Smeets wrote: Hello, I'm trying to write a script which detects when a new removable drive is connected to the computer. On #python I was advised to use the dbus-bindings. However the documentation on this is limited. Does anyone know of an example

  1   2   3   >