Google Web Search API

2015-04-29 Thread brad . ahlers
Does anyone know of any current Python projects that utilize Google's search engine to return quick answers to questions? For example, if you Google "When did Abraham Lincoln die", Google returns "April 15, 1865" before listing any results. I know of many projects that utilize Google search to r

Re: subprocess command fails

2015-02-20 Thread Brad s
fixed with now = datetime.datetime.now() later = now + datetime.timedelta(days=2*365) striplater = later.strftime('%Y%m%d%H') # python3.4 makekeys.py Enter the domain to configure keys for? test1234.com Generating key pair..

Re: subprocess command fails

2015-02-20 Thread Brad s
Time adjustment error: # python3.4 timefix.py 2015022105 2015-02-21 05:00:00 Traceback (most recent call last): File "timefix.py", line 15, in ndate = datetime.datetime.strptime(timeadd, '%Y%m%d%H') TypeError: must be str, not datetime.datetime # cat timefix.py #!/usr/bin/python3.4 impor

Re: subprocess command fails

2015-02-20 Thread Brad s
Yes, the program deletes the same files it produces. It looks to see if old stuff is there and if it exist, it deletes the files and creates and entirely new DNS zone with keys and then it is supposed to sign it. The last step is where it is still failing but your code helped me to figure out wh

subprocess command fails

2015-02-20 Thread Brad s
# cat makekeys.py #!/usr/bin/python3.4 import subprocess import sys import string import os.path import datetime import shlex from time import gmtime, strftime from subprocess import Popen, PIPE, STDOUT pretime = strftime("%Y%m%d%H", gmtime()) time = datetime.datetime.strptime(pretime,'%Y%m%d%H')

Re: Venus / GuthVenus for iPhone, Nexus, Droid and Android Jelly Bean

2014-03-17 Thread Brad Guth
On 3/17/2014 3:33 PM, Thrinaxodon wrote: In article <71ab5220-6d5d-46bf-b33a-16aae6c87...@googlegroups.com>, bradg...@gmail.com says... On Wednesday, February 5, 2014 2:59:23 PM UTC-8, Brad Guth wrote: On Saturday, January 11, 2014 3:52:10 PM UTC-8, Brad Guth wrote: NOVA and Dis

Re: emacs user interface design? a talk by Bret Victor

2012-02-27 Thread Brad
On Feb 26, 7:01 pm, NanoThermite FBibustards wrote: > @Xah Lee, he only tell one point, fast interpreter avoiding Edit- > Compile-Run cycle, and make it INTERACTIVE, the guy did not teach > nothing of design. The principle was first given by Margaret Hamilton > and Zeldin. > Bret's main point is t

Re: signed to unsigned

2012-02-17 Thread Brad Tilley
> >>> 0x & -327681234 > > 3967286062 Very nice! Thanks for that example. Unsigned long longs: 0x & -9151314442815602945 9295429630893948671L -- http://mail.python.org/mailman/listinfo/python-list

Re: signed to unsigned

2012-02-17 Thread Brad Tilley
gt; >>> unpack('=I', pack('=i',-327681234)) > > (3967286062,) > > I would think there's some more efficient way to do this though. > > Cheers, > Chris Thanks Chris! I was doing it backwards. I only have a few of these right now, so performance isn't a concern. I appreciate the advice. Brad -- http://mail.python.org/mailman/listinfo/python-list

signed to unsigned

2012-02-17 Thread Brad Tilley
In C or C++, I can do this for integer conversion: unsigned int j = -327681234; // Notice this is signed. j will equal 3967286062. I thought with Python that I could use struct to pack the signed int as an unsigned int, but that fails: >>> x = struct.pack("", line 1, in struct.error: integer ou

Re: Make a small function thread safe

2011-12-16 Thread Brad Tilley
than the explicit acquire() and release() so I'll use that approach. I appreciate your advice. Brad -- http://mail.python.org/mailman/listinfo/python-list

Re: Make a small function thread safe

2011-12-16 Thread Brad Tilley
On Fri, Dec 16, 2011 at 9:24 AM, Brad Tilley wrote: > > > On Fri, Dec 16, 2011 at 8:33 AM, Tim Wintle wrote: > >> On Fri, 2011-12-16 at 05:21 -0800, Brad Tilley wrote: >> > 107 void increment_counter( unsigned int& counter ) >> > 108

Re: Make a small function thread safe

2011-12-16 Thread Brad Tilley
On Fri, Dec 16, 2011 at 8:33 AM, Tim Wintle wrote: > On Fri, 2011-12-16 at 05:21 -0800, Brad Tilley wrote: > > 107 void increment_counter( unsigned int& counter ) > > 108 { > > 109 boost::mutex::scoped_lock lock( counter_lock ); > >

Make a small function thread safe

2011-12-16 Thread Brad Tilley
++counter; 111 } A thread locks the function on entrance and then releases it on exit. What is the equivalent way to do this in Python? Many thanks! Brad -- http://mail.python.org/mailman/listinfo/python-list

python 3 - instantiating class from user input

2011-04-06 Thread Brad Bailey
I dont understand why this is such a big deal. Nor do i understand why google can't find a reasonable answer. If one can't figure out from the title what I'm trying to do, then a look at code should firmly plant the intent. The general idea of the code is, in my opinion, very basic. I notice,

Python CPU

2011-04-01 Thread Brad
Hi All, I've heard of Java CPUs. Has anyone implemented a Python CPU in VHDL or Verilog? -Brad -- http://mail.python.org/mailman/listinfo/python-list

RE: Python Tools for Visual Studio from Microsoft - Free & Open Source

2011-03-13 Thread Brad Davies
> From: pa...@cruzio.com > To: santacruz-...@hotmail.com > Subject: Fw: Python Tools for Visual Studio from Microsoft - Free & Open > Source > Date: Thu, 10 Mar 2011 18:47:19 -0800 > > > - Original Message - > From: > To: "roland garros" ; > Sent: Thursday, March 10, 2011 2:03 AM >

Python SIG for Healthcare IT

2011-03-11 Thread Brad Allen
For those seeking to work with Python-based tools in the healthcare IT industry, this SIG ("special interest group") can provide a forum to discuss challenges and hopefully foster knowledge sharing and tools development. Relevant topics include tools for working with healthcare standard data format

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-26 Thread Brad
On Aug 25, 4:05 am, Alex McDonald wrote: > Your example of writing code with > memory leaks *and not caring because it's a waste of your time* makes > me think that you've never been a programmer of any sort. "Windows applications are immune from memory leaks since programmers can count on regula

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-21 Thread Brad
p.lang.forth have a penchant for sarcasm - one of the reasons I always read their posts. Maybe it gets lost on the international crowd, but I love it. -Brad -- http://mail.python.org/mailman/listinfo/python-list

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Brad
data, which you may find preferable to an ugly crash. OTOH, bugs that cause spectacular failures tend to be discovered. You can also initialize the stack memory with a pattern like 0xDEAD and then after sufficiently exercising the code, examine the memory contents to see the "high water mark

Re: Can I make sqlite3 or shelve work reliably on any Win/Linux/Mac?

2010-02-22 Thread Brad Harms
started: import sys # Linux binary if 'linux' in sys.platform.lower(): import _sqlite3_linux as _sqlite3 # Windows binary elif 'win32' == sys.platform: import _sqlite3_windows as _sqlite3 # Mac binary elif 'darwin' == sys.platform: import _sqlite3_m

Re: method to intercept string formatting % operations

2010-02-05 Thread Brad Allen
On Fri, Feb 5, 2010 at 9:49 AM, Jean-Michel Pichavant wrote: > Anyway why would you want to use the tuple form ? it's beaten in every > aspect by the dictionary form. I'm subclassing a namedtuple, and adding some additional functionality such as __getitem__, __setitem__, so that the namedtuple a

Re: KeyboardInterrupt

2009-12-09 Thread Brad Harms
a script since you never know when the user will press it, which is why you put the try: except KeyboardInterrupt: around as much of your script as possible. The signal that the OS sends to the Python interpreter is irrelevant. -- Brad Harms -- http://alphaios.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Feature request: String-inferred names

2009-12-04 Thread Brad Harms
erm, because it's too cumbersome to say "properties or dynamic attributes using __getattr__ or __getattribute__" all the time. That will be my last message for a while...good night, c.p.l. -- Brad Harms -- http://alphaios.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Feature request: String-inferred names

2009-12-04 Thread Brad Harms
On Fri, 04 Dec 2009 18:05:03 +1100, Ben Finney wrote: > Brad Harms writes: > >> Anyway, it looks like the docs agree with you >> (http://docs.python.org/glossary.html#term-attribute), so I'm not going >> to argue. > > That's good, because the te

Re: Feature request: String-inferred names

2009-12-03 Thread Brad Harms
On Tue, 2009-12-01 at 16:58 +0100, Bruno Desthuilliers wrote: > The Music Guy a écrit : > (snip) > > Lie Ryan, I think I see what you're saying about using __dict__ to add > > members > > No "members" in Python - only attributes. > > to a class, but it's not quite the same. __dict__ is only for >

Re: Feature request: String-inferred names

2009-12-03 Thread Brad Harms
On Tue, 2009-12-01 at 14:38 +, Steven D'Aprano wrote: > On Mon, 30 Nov 2009 18:55:46 -0800, The Music Guy wrote: > > > Lie Ryan, I think I see what you're saying about using __dict__ to add > > members to a class, but it's not quite the same. __dict__ is only for > > attributes, NOT properties

Re: Feature request: String-inferred names

2009-11-29 Thread Brad Harms
st definition of an attribute, but it's the best I can think of ATM.) I'm not trying to discard Python's distinction between items and attributes, but I don't want to be limited by it due to mere syntactical constraints, either. May the Penguin in the sky bless your every subroutine, Brad Harms -- http://mail.python.org/mailman/listinfo/python-list

Re: Feature request: String-inferred names

2009-11-29 Thread Brad Harms
On Sun, Nov 29, 2009 at 7:49 PM, Lie Ryan wrote: > On 11/29/2009 12:22 PM, The Music Guy wrote: > >> When I first started seeing @ show up in Python code, I said "what the >> heck is that? It looks so weird and _ugly_.I would never try to mess >> with that." But I started seeing it more and more,

Re: Feature request: String-inferred names

2009-11-25 Thread Brad
On Nov 25, 10:49 pm, Chris Rebert wrote: > On Wed, Nov 25, 2009 at 6:35 PM, The Music Guy > > wrote: > > Hello all, > > > I just posted to my blog about a feature that I'd like to see added to > > Python. Before I go through the trouble of learning how to write a PEP or > > how to extend the Pyth

Re: Sequence splitting

2009-07-03 Thread Brad
g = partition(words, lambda w: len(w) < 3) d = {1 : 'w', 2 : 'x' ,3 : 'y' ,4 : 'z'} keys = [1, 3, 4, 9] found, missing = partition(keys, d.has_key) There are probably a dozen other approaches, but the existing "filter" is fast, clear, and *almos

Re: Sequence splitting

2009-07-02 Thread Brad
You are not allowed to post to this mailing list" reply. Perhaps because I am posting through Google groups? Or maybe one must be an approved member to post? -Brad -- http://mail.python.org/mailman/listinfo/python-list

Re: Sequence splitting

2009-07-02 Thread Brad
the solution here would worse if func was more complex. Either way, what I am still wondering is if people would find a built- in implementation useful? -Brad -- http://mail.python.org/mailman/listinfo/python-list

Re: Sequence splitting

2009-07-02 Thread Brad
On Jul 2, 9:08 pm, Paul Rubin <http://phr...@nospam.invalid> wrote: > Brad writes: > > On Jul 2, 8:14 pm, Paul Rubin <http://phr...@nospam.invalid> wrote: > > > schickb writes: > > > > def split(seq, func=None): > > > >     if func

Re: Sequence splitting

2009-07-02 Thread Brad
On Jul 2, 8:17 pm, "Pablo Torres N." wrote: > On Jul 2, 9:56 pm, schickb wrote: > > > I have fairly often found the need to split a sequence into two groups > > based on a function result. > > This sounds like it belongs to the python-ideas list.  I suggest > posting there for better feedback, si

Re: Sequence splitting

2009-07-02 Thread Brad
or (x,y) in xs if not y) >       return (t, f) In my testing that is 3.5x slower than the original solution (and less clear imo). I fixed my version to take a bool default. Either way, I'm not really looking for additional ways to do this in Python unless I've totally missed something

VERY simple string comparison issue

2008-12-24 Thread Brad Causey
P:// is somehow affecting the searching capabilities of the string.find function. But I can't seem to locate any documentation online that outlines restrictions when using special characters. Any thoughts? Thanks! -Brad -- http://mail.python.org/mailman/listinfo/python-list

String Comparison Testing

2008-12-24 Thread Brad Causey
P:// is somehow affecting the searching capabilities of the string.find function. But I can't seem to locate any documentation online that outlines restrictions when using special characters. Any thoughts? Thanks! -Brad Causey CISSP, MCSE, C|EH, CIFI Zero Day Consulting -- http://mail.python.org/mailman/listinfo/python-list

Re: curses.setsyx()?

2008-09-23 Thread brad . at . school
On Sep 22, 11:24 pm, Tim Roberts <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > >On Sep 19, 6:42 pm, [EMAIL PROTECTED] wrote: > >> On Sep 19, 1:24 am, Tim Roberts <[EMAIL PROTECTED]> wrote: > > >> > [EMAIL PROTECTED] wrote: > > >> > >I tried curses.setsyx(2,3) in my script and it doesn't m

Re: Python multimap

2008-08-28 Thread brad
Carl Banks wrote: Out of curiosity, what does a true multimap solve that a dictionary of lists not solve? Nothing really. I went with a variation of the suggested work around... it's just that with Python I don't normally have to use work arounds and normally one obvious approach is correct:

Re: Python multimap

2008-08-27 Thread brad
castironpi wrote: I don't understand what a multimap does that a map of lists doesn't do. It counts both keys individually as separate keys. The Python workaround does not... see examples... notice the key(s) that are '4' Python output (using the k = [] idea): Key: 4 Value: [[13, 'Visa'],

Re: Python multimap

2008-08-27 Thread brad
Mike Kent wrote: Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. k = {} k['1'] = [] k['1'].append('Tom') k['1'].append('Bob') k['1'].append('Joe') k['1'] ['Tom', 'Bob', 'Joe']

Python multimap

2008-08-27 Thread brad
Recently had a need to us a multimap container in C++. I now need to write equivalent Python code. How does Python handle this? k['1'] = 'Tom' k['1'] = 'Bob' k['1'] = 'Joe' ... Same key, but different values. No overwrites either....

Re: Formatting input text file

2008-08-14 Thread brad
[EMAIL PROTECTED] wrote: Hi, it's me again with tons of questions. I hava an input file structured like this: X XYData-1 1. 3.08333 > number1 number2 number3 number4 number5 number6 split is your friend. -- http://mail

Re: Suggestion for converting PDF files to HTML/txt files

2008-08-12 Thread brad
alex23 wrote: On Aug 12, 11:13 pm, brad <[EMAIL PROTECTED]> wrote: Very neat program. Would be cool if it could easily integrate into other py apps instead of being a standalone CLI tool. Perhaps, but I think you could get a long way using os.system(). Yes, that is possible, but the

Re: Suggestion for converting PDF files to HTML/txt files

2008-08-12 Thread brad
alex23 wrote: PDFMiner is a set of CLI tools written in Python, one of which converts PDF to text, HTML and more: http://www.unixuser.org/~euske/python/pdfminer/index.html Very neat program. Would be cool if it could easily integrate into other py apps instead of being a standalone CLI tool.

Re: Editing a file by substitution

2008-08-11 Thread Brad
alex23 wrote: On Aug 12, 12:03 pm, Brad <[EMAIL PROTECTED]> wrote: So let's say I want to edit this file and change Volume from 940 to 950. Personally, I'd recommend avoiding re and sticking with the standard string functions. Something like this should be pretty effective:

Editing a file by substitution

2008-08-11 Thread Brad
Hi, what I'd like to do is edit an input file for a calculation with Python. Let's say that I have an input file like the following -->> BLAH BLAH BLAH Other inputs, Volume 940 m^3, maybe some more stuff STUFF STUFF -->> So let's say I

Re: os.system question

2008-08-11 Thread Brad
Kevin Walzer wrote: >>> import os >>> foo = os.system('whoami') kevin >>> print foo 0 >>> The standard output of the system command 'whoami' is my login name. Yet the value of the 'foo' object is '0,' not 'kevin.' How can I get the value of 'kevin' associated with foo? Hi Kevin, check

Re: Suggestion for converting PDF files to HTML/txt files

2008-08-11 Thread brad
srinivasan srinivas wrote: Could someone suggest me ways to convert PDF files to HTML files?? Does Python have any modules to do that job?? Thanks, Srini Unless there is some recent development, the answer is no, it's not possible. Getting text out of PDF is difficult (to say the least) and a

regex search loops instead of findall

2008-08-05 Thread brad
Hi guys... I'm trying to make my Python regex code behave like my C++ regex code. In order to search large strings for *all* occurrences of the thing I'm searching for, I loop like this in C++: void number_search(const std::string& portion, const boost::regex& Numbers) { boost::smatch m

Re: What Python looks like

2008-08-05 Thread brad
Gary Herron wrote: My impression was (and still is): A page of Python code looks *clean*, with not a lot of punctuation/special symbols and (in particular) no useless lines containing {/} or begin/end or do/done (or whatever). what about all those 'self' thingys? :) -- http://mail.python.o

Re: Wrapping C with Python

2008-08-04 Thread brad
RPM1 wrote: ... Basically you just compile your C code as a regular C code dll. ctypes then allows you to access the functions in the dll very easily. Does that work with C++ code too or just C? -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular expression help

2008-07-18 Thread Brad
[EMAIL PROTECTED] wrote: Hello, I am new to Python, with a background in scientific computing. I'm trying to write a script that will take a file with lines like c afrac=.7 mmom=0 sev=-9.56646 erep=0 etot=-11.020107 emad=-3.597647 3pv=0 extract the values of afrac and etot... Why not just sp

Looking for lots of words in lots of files

2008-06-18 Thread brad
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 some of the words are in the files. I can stop reading a file once I find 10 of the words in i

Programming question

2008-06-11 Thread Brad Navarro
I am stuck with 1.5. Thanks, Brad -- http://mail.python.org/mailman/listinfo/python-list

Re: MVC

2008-05-22 Thread Brad
ts the use of design patter. So, here goes my question. Is that OK if I follow this? ... Yes. Python does not impose design patterens onto developers. Pick your poison. It is somewhat OOP, but allows for other development paradigms as well... rather like C++ IMO although a bit more OOP focused.

Re: Python is slow

2008-05-22 Thread Brad
cm_gui wrote: Python is slow. It ain't C++, but it ain't a punch card either... somewhere in between. I find it suitable for lots of stuff. I use C++ when performance really matters tho... right tool for the job. Learn a good interpreted language (Pyhton) and a good compiled language (C or C

Re: Shell-independent *nix setup script

2008-05-22 Thread brad
[EMAIL PROTECTED] wrote: Hi, Is it worthwhile maintaining a production application setup script in Python as opposed to shell-script? I do not think so. Perhaps 'in conjunction with', but not 'opposed to'... sh is the lowest common denominator of shells. Script for sh and your script will r

Re: problem boost::python::import

2008-05-22 Thread brad
Frédéric Degraeve wrote: Hello, I tried this code with vs7-8 and boost1.34.1-1.35.0 and my python is a 2.4.. Try the boost users list: To subscribe or unsubscribe via the World Wide Web, visit http://lists.boost.org/mailman/listinfo.cgi/boost-users -- http://mail.python.org/mailman/lis

Re: Using Python for programming algorithms

2008-05-20 Thread brad
Vicent Giner wrote: The usual answer is that development time is more important than running time. This depends. Run time is not important until you are asked to scale to millions or billions of users or computations or large data sets. I've seen this first hand. Getting results back the sa

Pass data from Python to C++

2008-05-15 Thread brad
utationally heavy info to c++ from within Pyhton. os.system is not ideal. Just wondering how other folks do this? I have source to some of the c++ code, but some of it is in binary from only. It can take stdin or arguments. Thanks for any tips, Brad -- http://mail.python.org/mailman/listinfo/python-list

comparing dictionaries

2008-05-07 Thread brad
I want to compare two dicts that should have identical info just in a different data structure. The first dict's contents look like this. It is authoritative... I know for sure it has the correct key value pairs: {'001' : '01'} The second dict's contents are like this with a tuple instead of a

Re: some path issues on windows

2008-03-28 Thread Brad
Steven D'Aprano wrote: > On Fri, 28 Mar 2008 22:31:07 -0400, Brad wrote: > >> When reading a file into a list that contains windows file paths like >> this: >> >> c:\documents and settings\brad\desktop\added_software\asus\a.txt >> >> I get a list t

some path issues on windows

2008-03-28 Thread Brad
When reading a file into a list that contains windows file paths like this: c:\documents and settings\brad\desktop\added_software\asus\a.txt I get a list that contains paths that look like this: c:\\documents and settings\\brad\\desktop\\added_software\\asus\\a.txt So, my list contains those

Understanding While Loop Execution

2008-02-18 Thread Brad
Hi folks, I'm still fairly new to programming in python and programming in general. A friend of mine is in a CompSci 101 course and was working on a slider game when he encountered a problem. We eventually figured out what the problem was and built a test case to help solve it, but I can't for the

Re: Email Directly from python

2008-02-13 Thread brad
Martin P. Hellwig wrote: > The tricky part is how to resolve the mail server for a mail address. > Usually you have to query the mx record of that domain. I solved that by > looking if I can find the nslookup binary. The from and to are static constants... they don't change. Mail just seems s

Email Directly from python

2008-02-13 Thread brad
n the machine? Thanks, Brad -- http://mail.python.org/mailman/listinfo/python-list

Python 3000 and import __hello__

2008-01-19 Thread Brad
Just playing around with Python3000 a2 release on Windows XP 32-bit x86. import __hello__ doesn't print 'hello world...' as it does on 2.5 The import doesn't fail or generate errors... just no output. Perhaps this is by design? Brad -- http://mail.python.org/mailman/listinfo/python-list

Patches to Python 2.5.1

2008-01-06 Thread Brad
I was just looking through the 2.5.1 source code. I noticed a few mis-spellings in the comments. No big deal really. Can patches be submitted that correct the spelling errors or should they just be pointed out to some mailing list? Thanks, Brad -- http://mail.python.org/mailman/listinfo

Understanding tempfile.TemporaryFile

2007-12-27 Thread Brad
Wondering if someone would help me to better understand tempfile. I attempt to create a tempfile, write to it, read it, but it is not behaving as I expect. Any tips? >>> x = tempfile.TemporaryFile() >>> print x ', mode 'w+b' at 0xab364968> >>> print x.read() >>> print len(x.read()) 0 >>> x

Re: A Python 3000 Question

2007-10-30 Thread brad
Eduardo O. Padoan wrote: > This is a FAQ: > http://effbot.org/pyfaq/why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-len-list.htm Thanks to all for the feedback. I'm no language designer. I just see and hear these criticisms and I wanted to think thro

Re: setting variables in outer functions

2007-10-29 Thread brad
Tommy Nordgren wrote: >> def outer(avar=False): >> print avar >> if avar == True: >> return >> >> def inner(avar=True): >> print avar >> return avar >> >> outer(inner()) >> >> outer() > This is not a general solution to this problem. Run my exam

Re: A Python 3000 Question

2007-10-29 Thread brad
Rob Wolfe wrote: > I wonder why people always complain about `len` function but never > about `iter` or `pprint.pprint`? :) Not complaining. len is simple and understandable and IMO fits nicely with split(), strip(), etc... that's why I used it as an example, but list(), etc. could be used as e

Re: setting variables in outer functions

2007-10-29 Thread brad
Tommy Nordgren wrote: > Given the following: > def outer(arg) > avar = '' > def inner1(arg2) > # How can I set 'avar' here ? Try this... works for me... maybe not for you? def outer(avar=False): print avar if avar == True: return def inner(avar=True):

A Python 3000 Question

2007-10-29 Thread brad
Will len(a_string) become a_string.len()? I was just reading http://docs.python.org/dev/3.0/whatsnew/3.0.html One of the criticisms of Python compared to other OO languages is that it isn't OO enough or as OO as others or that it is inconsistent. And little things such as this seem to support t

Re: python2.5 and mysqldb

2007-10-29 Thread brad
sily allows for this sort of thing (like Debian) Brad -- http://mail.python.org/mailman/listinfo/python-list

Re: test if email

2007-10-12 Thread brad
[EMAIL PROTECTED] wrote: > On Oct 12, 2:55 pm, Florian Lindner <[EMAIL PROTECTED]> wrote: >> Hello, >> is there a function in the Python stdlib to test if a string is a valid >> email address? here's a Perl re example... I don't know whether to laugh or cry... don't try to replicate this in Pytho

Re: test if email

2007-10-12 Thread brad
Grant Edwards wrote: > If you send an e-mail to an address and you get a response, > then it's valid. No response could be valid too. The user may not respond. For automated tasks, I go with the no bounce method. When things start bouncing, do domething, but so long as they don't bounce do some

Re: test if email

2007-10-12 Thread brad
Florian Lindner wrote: > Hello, > is there a function in the Python stdlib to test if a string is a valid > email address? Nope, most any string with an @ in it could be a valid email addy. Send a message to the addy, if it doesn't bounce, then it's valid. -- http://mail.python.org/mailman/listi

Re: Memory Problems in Windows 2003 Server

2007-10-12 Thread brad
lot of memory. So, just because you have 2GB, that does not mean you can access all of that at once. I would guess that 25% of memory is in constant use by the OS. So, do your IO/reads in smaller chunks similar to the example I gave earlier. Brad -- http://mail.python.org/mailman/listinfo/python-list

Re: Memory Problems in Windows 2003 Server

2007-10-12 Thread brad
amdescombes wrote: > Hi, > > I am using Python 2.5.1 > I have an application that reads a file and generates a key in a > dictionary for each line it reads. I have managed to read a 1GB file and > generate more than 8 million keys on an Windows XP machine with only 1GB > of memory and all works

Re: Finding Peoples' Names in Files

2007-10-11 Thread brad
rtunately, there is no luhn check for SSNs. We follow the Social Security Administration verification guideline religiously... here's an web front-end to my logic: http://black.cirt.vt.edu/public/valid_ssn/index.html but still have many false positives on SSNs, so being able to id *names and

Re: Finding Peoples' Names in Files

2007-10-11 Thread brad
mes in it as well." Now then, I'd have less to review or perhaps as much as I have now, but I could push the files with numbers and names to the top of the list so that they would be reviewed first. Brad -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding Peoples' Names in Files

2007-10-11 Thread brad
[EMAIL PROTECTED] wrote: > On Oct 11, 5:22 pm, brad <[EMAIL PROTECTED]> wrote: >> Crazy question, but has anyone attempted this or seen Python code that >> does? For example, if a text file contained 'Guido' and or 'Robert' and >> or 'Susan&

Finding Peoples' Names in Files

2007-10-11 Thread brad
Crazy question, but has anyone attempted this or seen Python code that does? For example, if a text file contained 'Guido' and or 'Robert' and or 'Susan', then we should return True, otherwise return False. -- http://mail.python.org/mailman/listinfo/python-list

Re: I'm starting to think like a Pythonista

2007-10-10 Thread brad
Erik Jones wrote: > big_evens = range(10, 100, 2) > big_odds = range(11, 100, 2) Neat, but not as clever or as hard to read as mine... I'll bet it faster though... maybe not. The upto part is here: ok_numbers = low_odds + big_evens + [x for x in low_evens if x <= y] -- http://mail.python.org

Re: I'm starting to think like a Pythonista

2007-10-10 Thread brad
Bjoern Schliessmann wrote: > brad wrote: >> low_odds = [1,3,5,7,9] >> # make a list containing 10 - 98 evens only >> big_evens = big_evens = [x for x in list(xrange(99)) if x % 2 == >> 0 and x >8] > > Why use xrange if you convert it to a full list in place

Re: if then elif

2007-10-10 Thread brad
Shawn Minisall wrote: > I just learned about if, then elif statements and wrote this program. > The problem is, it's displaying all of the possibilities even after you > enter a 0, or if the fat grams are more then the total number of > calories , that is supposed to stop the program instead of

I'm starting to think like a Pythonista

2007-10-10 Thread brad
I was looking at a way to implement Ruby's upto method in python. I came up with the code below... three years ago, I would never have thought of list comprehension, today it seems second nature. This may be totally un-Pythonic, but I thought it was kind of clever. Man, for some reason, I feel

Re: Program with wx in Linux and Windows

2007-10-05 Thread brad
). I write/test > on Linux, and the programs pretty much "just work" on Windows. That sums up my experience with wxPython as well. I've never had any problems. I develop on Linux and run on Linux, Mac and Windows. Brad -- http://mail.python.org/mailman/listinfo/python-list

unit testing

2007-10-04 Thread brad
(the official unittest that is)... especially when there's a lot of source code. But this... if len(x) != y: sys.exit('...') is a hell of a lot easier and quicker that subclassing unittest.TestCase on small projects :) Do others do their own "informal" unit test

List Question

2007-10-02 Thread brad
How is this expressed in Python? If x is in y more than three times: print x y is a Python list. -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionary invalid token error

2007-10-02 Thread brad
Tim Chase wrote: > Numbers with leading zeros are parsed as octal. 8 and 9 are invalid > digits in octal. Thus, it falls over. 00 through 07 will work fine, > but 08 and 09 will go kaput. > > http://docs.python.org/ref/integers.html > > -tkc Thanks... that makes sense. I'll store them as st

Dictionary invalid token error

2007-10-02 Thread brad
This works: >>> area_group = {001:06, 002:04, 003:04, 006:9} This does not (one the end, 09 is used instead of 9) >>> area_group = {001:06, 002:04, 003:04, 006:09} File "", line 1 area_group = {001:06, 002:04, 003:04, 006:09} SyntaxError: invalid token Why does 09 cause an invalid tok

Re: Reentrancy of Python interpreter

2007-10-01 Thread Brad Johnson
Hrvoje Niksic xemacs.org> writes: > > Brad Johnson ballardtech.com> writes: > > > I have a place where I execute a Python command that calls into C++ > > code which then in turn calls back into Python using the same > > interpreter. I get a fatal erro

slice last 4 items from a list

2007-10-01 Thread brad
Is this the correct way to slice the last 4 items from a list? x = [1,2,3,4,5,6,7,8,9] print x[-4:] It works, but is it Pythonic? -- http://mail.python.org/mailman/listinfo/python-list

Re: Reentrancy of Python interpreter

2007-10-01 Thread Brad Johnson
yahoo.com> writes: > Looks like ( from PyThreadStage_Get error ) that you lost the GIL. You > probably > entered some C++ code and encapsulated you're work in the > > Py_BEGIN_ALLOW_THREADS > > Py_END_ALLOW_THREADS > > but you're is calling back the Python function, and you forgot > to acqui

Reentrancy of Python interpreter

2007-09-28 Thread Brad Johnson
I have embedded a single threaded instance of the Python interpreter in my application. I have a place where I execute a Python command that calls into C++ code which then in turn calls back into Python using the same interpreter. I get a fatal error which is "PyThreadStage_Get: no current thread.

  1   2   >