Re: Path difficulties with Python 2.5 running on Cygwin

2009-05-08 Thread Jerry Hill
On Fri, May 8, 2009 at 11:29 AM, walterbyrd wrote: > I accidently named a script csv.py, put I deleted that. You probably still have a stale csv.pyc in that directory. Delete that too. To tell for sure, open the python interpreter and do: import csv print csv.__file__ That will tell you exactl

Re: passing *args "recursively"

2008-05-12 Thread Jerry Hill
On Mon, May 12, 2008 at 12:19 PM, Guillermo <[EMAIL PROTECTED]> wrote: > def func1(*args): > print args # (1, 2, 3) > func2(args) change this line to: func2(*args) -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: thread stomp?

2008-05-12 Thread Jerry Hill
On Mon, May 12, 2008 at 4:00 PM, pyn3wb <[EMAIL PROTECTED]> wrote: > class main Why are you making main a class? It should almost certainly be a function (defined with "def", not "class"). > for i in dircache.listdir(dir): > //run over files > class1(dir)

Re: built in list generator?

2008-05-13 Thread Jerry Hill
On Tue, May 13, 2008 at 4:05 PM, globalrev <[EMAIL PROTECTED]> wrote: > if i want a list with all numbers between x and y is there a way to > do this with an inbult function. > > i mean i can always construct a function to do this but is there > soemthing like: > > nbrs = list(range(50,100, 2)

Re: Database Query Contains Old Data

2008-05-21 Thread Jerry Hill
On Wed, May 21, 2008 at 6:30 AM, <[EMAIL PROTECTED]> wrote: > The first time you run a report, everything works as expected but if > you run it a second time, after modifying data, it seems that the data > from before the modification is selected on the second report run. Did you remember to comm

Re: Bug in floating-point addition: is anyone else seeing this?

2008-05-21 Thread Jerry Hill
On Wed, May 21, 2008 at 4:34 PM, Dave Parker <[EMAIL PROTECTED]> wrote: > On May 21, 12:38 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > >> >>> a+0.999 # gives expected result >> 9998.0 >> >>> a+0. # doesn't round correctly. >> >> 1.0 > > Shouldn't both of th

Re: Why is math.pi slightly wrong?

2008-05-22 Thread Jerry Hill
On Thu, May 22, 2008 at 12:32 PM, Dutton, Sam <[EMAIL PROTECTED]> wrote: > I've noticed that the value of math.pi -- just entering it at the interactive > prompt -- is returned as 3.1415926535897931, whereas (as every pi-obsessive > knows) the value is 3.1415926535897932... (Note the 2 at the end

Re: Storing objects in relational database

2008-05-23 Thread Jerry Hill
On Fri, May 23, 2008 at 5:07 PM, nayden <[EMAIL PROTECTED]> wrote: > The reason I am writing here is that I can't seem to figure out how to > save/restore python objects into a relational database. Here's a basic version using the sqlite bindings included with Python 2.5: import sqlite3, pickle

Re: problems with opening files due to file's path

2008-06-11 Thread Jerry Hill
On Wed, Jun 11, 2008 at 4:16 PM, Alexnb <[EMAIL PROTECTED]> wrote: > > I posted the underlying code, but I haven't made the GUI code because if I > can't get the underlying code right it doesn't matter, well in my eyes it > doesn't but I am probably wrong. But it will look somehting like this: Wha

Re: Hrounding error

2008-06-18 Thread Jerry Hill
On Wed, Jun 18, 2008 at 1:47 AM, <[EMAIL PROTECTED]> wrote: 234 - 23234.2345 > -23000.2344 > > This is not correct by my calculations. Python floating point operations use the underlying C floating point libraries which, in turn, usually rely on the hardware's floating point implemen

Re: URLLIb2 problem

2008-06-30 Thread Jerry Hill
On Mon, Jun 30, 2008 at 4:11 PM, <[EMAIL PROTECTED]> wrote: > I am trying to write somecode of this kind :) > > opener = urllib2.build_opener(urllib2.HTTPCookieProcessor()) > opener.addheaders = [ ... > ('Accept-Encoding','gzip,deflate'), ... > urllib2.install_opener(opener) > > fu = urllib2.urlop

Re: Confused yet again: Very Newbie Question

2008-07-07 Thread Jerry Hill
On Mon, Jul 7, 2008 at 7:30 AM, mcl <[EMAIL PROTECTED]> wrote: > I did not think you had to make the distinction between 'byvar' and > 'byref' as in Basic. Python does not use "call by value" or "call by reference" semantics. Instead, python's model is "call by object". See this writeup for some

Re: problem with Tkinter after installing Python 2.5.2 on UBUNTU

2008-07-08 Thread Jerry Hill
On Tue, Jul 8, 2008 at 12:44 PM, <[EMAIL PROTECTED]> wrote: > I just installed Python 2.5.2 on UBUNTU Linux. It seems to work, > however I don't seem to have access Tkinter. This is the result of > "import Tkinter": I think ubuntu and debian both split Tkinter out of their main python packages.

Re: formatting list -> comma separated

2008-07-09 Thread Jerry Hill
On Wed, Jul 9, 2008 at 3:23 PM, Robert <[EMAIL PROTECTED]> wrote: > given d: > d = ["soep", "reeds", "ook"] > > I want it to print like > soep, reeds, ook use the join() method of strings, like this: >>> d = ["soep", "reeds", "ook"] >>> ', '.join(d) 'soep, reeds, ook' >>> d = [] >>> ', '.join(d) '

Re: Filechooser issues

2008-07-11 Thread Jerry Hill
On Fri, Jul 11, 2008 at 3:09 PM, Mr SZ <[EMAIL PROTECTED]> wrote: > ff = gtk.FileFilter.add_pixbuf_formats() > The documentation doesn't say anything about an argument to be passed: > http://www.pygtk.org/docs/pygtk/class-gtkfilefilter.html#method-gtkfilefilter--add-pixbuf-formats I don't kno

Re: Unicode confusion

2008-07-14 Thread Jerry Hill
On Mon, Jul 14, 2008 at 12:40 PM, Tim Cook <[EMAIL PROTECTED]> wrote: > if I say units=unicode("°"). I get > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: > ordinal not in range(128) > > If I try x=unicode.decode(x,'utf-8'). I get > TypeError: descriptor 'decode' requires

Re: Bug when using with_statement with exec

2008-07-14 Thread Jerry Hill
On Mon, Jul 14, 2008 at 6:00 PM, Matimus <[EMAIL PROTECTED]> wrote: > If I create a function by using exec on a string and _don't_ end the > string with a new-line it will work just fine unless I "from > __future__ import with_statement". [snip] > I searched python's issue database and didn't see a

Re: Python embedding question.

2008-07-15 Thread Jerry Hill
On Tue, Jul 15, 2008 at 5:51 AM, Thomas Troeger <[EMAIL PROTECTED]> wrote: > Or is there a method to have gzipped > modules that are unzipped on the fly into memory when they're accessed? That > would be even better. Yes. See the documentation for the zipimport module, and PEP 273. http://docs.p

Re: 'if name is not None:' v. 'if name:'

2008-07-15 Thread Jerry Hill
On Tue, Jul 15, 2008 at 4:13 PM, Reedick, Andrew <[EMAIL PROTECTED]> wrote: > If name is None: >Then name is NULL, nothing, nada, no object, no memory allocated, a > NULL pointer This is just plain untrue. If 'name is None' evaluates to true, then the variable 'name' is bound to the singleton

Re: Get dict value but not as reference.

2008-07-23 Thread Jerry Hill
On Wed, Jul 23, 2008 at 11:49 AM, Robert Rawlins <[EMAIL PROTECTED]> wrote: > I have a dictionary, and I want to get one of the values from it, but rather > than returning it as a reference I want to actually detach/remove the > element from the dictionary. Like so: Use the pop() method of the dic

Re: Using variables across modules

2008-07-23 Thread Jerry Hill
On Wed, Jul 23, 2008 at 3:06 PM, Aaron Scott <[EMAIL PROTECTED]> wrote: > ... which is what I was expecting, but not what I want. Obviously, > each import is creating its own instance of the variable. What I need > is a way to change myvar from within "bar.py" so that PrintVar() > returns the new v

Re: How do I include a shell variable in my script?

2008-07-29 Thread Jerry Hill
On Tue, Jul 29, 2008 at 10:53 AM, laredotornado <[EMAIL PROTECTED]> wrote: > Hi, > > I'm running a Python script on a Solaris 9 machine, invoking the > Python script from ksh, if that matters. There is an enviornment > variable, $JAVA_HOME, that I would like to include in my script, > replacing "/

Re: Python parsing iTunes XML/COM

2008-07-30 Thread Jerry Hill
On Wed, Jul 30, 2008 at 10:58 AM, william tanksley <[EMAIL PROTECTED]> wrote: > Here's one example. The others are similar -- they have the same > things that look like problems to me. > > "Buffett Time - Annual Shareholders\xc2\xa0L.mp3" > > Note some problems here: > > 1. This isn't Unicode; it's

Re: Python parsing iTunes XML/COM

2008-07-30 Thread Jerry Hill
On Wed, Jul 30, 2008 at 2:27 PM, william tanksley <[EMAIL PROTECTED]> wrote: > Awesome... Thank you! I had my mental model of Python turned around > backwards. That's an odd feeling. Okay, so you decode to go from raw > byes into a given encoding, and you encode to go from a given encoding > to raw

Re: Python parsing iTunes XML/COM

2008-07-31 Thread Jerry Hill
On Thu, Jul 31, 2008 at 9:44 AM, william tanksley <[EMAIL PROTECTED]> wrote: > I'm using a file, a file that's correctly encoded as UTF-8, and it > returns some text elements that are raw bytes (undecoded). I have to > manually decode them. I can't reproduce this behavior. Here's a simple test ca

Re: problem calling parent's __init__ method

2008-08-07 Thread Jerry Hill
On Thu, Aug 7, 2008 at 11:11 AM, Ryan Krauss <[EMAIL PROTECTED]> wrote: > I am trying to call a parent's __init__ method from the child's: This works for me just fine: class InnerBlock(object): def __init__(self, codelist, noout=False, **kwargs): self.codelist = codelist self.

Re: dynamically creating html code with python...

2008-08-11 Thread Jerry Hill
On Mon, Aug 11, 2008 at 9:15 AM, <[EMAIL PROTECTED]> wrote: > [CODE] > f=StringIO.StringIO() > f.write('data analysis') > f.write(urllib.urlopen("http://localhost/path2Libs/myLibs.py";, > urllib.urlencode(TheData))) > f.write("") > > print "Content-type: text/html\n" > print f.read() > f.close()

Re: dynamically creating html code with python...

2008-08-11 Thread Jerry Hill
On Mon, Aug 11, 2008 at 12:26 PM, <[EMAIL PROTECTED]> wrote: > I have tried calling a script containing the code below from a web browser > and it did not get the text. You quoted my post that answered this question, but did not implement either of the two solutions I suggested. I continue to s

Re: python interpreter

2008-08-12 Thread Jerry Hill
On Tue, Aug 12, 2008 at 10:49 AM, Alexandru Mosoi <[EMAIL PROTECTED]> wrote: > I'm using python's interpreter's to run various commands (like a > normal shell). However if sources are modified changes are not > reflected so I have to restart interpreter. Is there any way to avoid > restarting this?

Re: Unable to lookup keys in dictionary

2008-08-12 Thread Jerry Hill
On Tue, Aug 12, 2008 at 11:27 AM, Matt Fielding (R* New England) <[EMAIL PROTECTED]> wrote: > [{'userName': 'mfielding', 'clientRoot': 'c:\\perforce', 'monitor': > 'enabled', > 'serverRoot': 'H:\\p4root\\', 'serverVersion': 'P4D/NTX64/2007.3/143793 > (2008/01/ > 21)', 'serverDate': '2008/08/12 11:1

Re: Hide raw_input text?

2008-08-13 Thread Jerry Hill
On Wed, Aug 13, 2008 at 1:26 PM, tmallen <[EMAIL PROTECTED]> wrote: > I'm working on a little FTP project to get comfortable with ftplib. > It's all terminal-based right now, and one issue I'm having is hiding > password input text. I'd like one of two things to happen with this: > Either don't sho

Re: default method parameter behavior

2008-04-02 Thread Jerry Hill
On Wed, Apr 2, 2008 at 3:59 PM, <[EMAIL PROTECTED]> wrote: > I ran into a similar situation like the following (ipython session). > Can anyone please explain why the behavior? http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects Since you got bitten by this, you

Re: question about string formatting

2008-04-09 Thread Jerry Hill
On Wed, Apr 9, 2008 at 1:04 PM, Kelie <[EMAIL PROTECTED]> wrote: > Is there something in Python built-in function or library that will convert > a number 1205466.654 to $1,205,466.65? To add the "$" sign and set the > decimal place is not a problem, but I don't know how to add the thousands > delim

Re: Python conventions

2008-04-10 Thread Jerry Hill
On Thu, Apr 10, 2008 at 3:52 PM, <[EMAIL PROTECTED]> wrote: > Daniel, PEP 8 is anything but complete. How much of the following > simple question can you answer from there: > > Given that you can name things with UpperAndLower, lowerAndUpper, > lower_and_underscore, etc., what is the conventio

Re: str class inheritance prob?

2008-04-16 Thread Jerry Hill
On Wed, Apr 16, 2008 at 2:35 PM, Hamish McKenzie <[EMAIL PROTECTED]> wrote: > so I'm trying to create a class that inherits from str, but I want to run > some code on the value on object init. this is what I have: You actually want to run your code when creating the new object, not when initializ

Re: Pickle problem

2008-04-18 Thread Jerry Hill
On Fri, Apr 18, 2008 at 11:55 AM, Mario Ceresa <[EMAIL PROTECTED]> wrote: > Hello everybody: > I'd like to use the pickle module to save the state of an object so to > be able to restore it later. The problem is that it holds a list of > other objects, say numbers, and if I modify the list and r

Re: why does the following with Queue, q.put('\x02', True) not put it in the queue?

2008-04-25 Thread Jerry Hill
On Fri, Apr 25, 2008 at 11:11 AM, Gabriel Rossetti <[EMAIL PROTECTED]> wrote: > yes, if you do it that way (s = '\x02') it works, but I read the data from > a file, and I that way it doesn't work It does work (using Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]

Re: Simple import question about mac osx

2008-04-29 Thread Jerry Hill
On Tue, Apr 29, 2008 at 2:14 PM, jmDesktop <[EMAIL PROTECTED]> wrote: > Thanks. That worked on mac. But it does work like I said in > Windows. Don't know why. Mr. Chun must also be using Windows because > that is the way he does it in his book. It shouldn't work that way on windows either.

Re: Simple import question about mac osx

2008-04-29 Thread Jerry Hill
On Tue, Apr 29, 2008 at 3:17 PM, jmDesktop <[EMAIL PROTECTED]> wrote: > On Windows I took the text file I created on mac with vi and opened it > in PythonWin. I ran it. It compiled. I run the import and call from > the python interpreter. You're not doing what you think you're doing. I'm no

Re: list.index crashes when the element is not found

2008-05-02 Thread Jerry Hill
On Fri, May 2, 2008 at 3:04 PM, TkNeo <[EMAIL PROTECTED]> wrote: > ofcouse try catch is going to work but in ideality the index function > should return a -1 and no way in hell crash. It doesn't crash. It raises an exception. This is a pretty fundamental concept of python programming. If you

Re: dict invert - learning question

2008-05-03 Thread Jerry Hill
On Sat, May 3, 2008 at 4:29 PM, dave <[EMAIL PROTECTED]> wrote: > here is a piece of code I wrote to check the frequency of values and switch > them around to keys in a new dictionary. Just to measure how many times a > certain key occurs: > > def invert(d): > inv = {} > for key

Re: web client in Python Q

2008-05-07 Thread Jerry Hill
On Wed, May 7, 2008 at 8:22 PM, Jive Dadson <[EMAIL PROTECTED]> wrote: > Hey folks. I know approximately zero about web clients. There's a simple > task I want to do. (I think it's probably simple.) And I figure a Python > script ought to be just the ticket. > > Various web services for daily st

Re: web client in Python Q

2008-05-08 Thread Jerry Hill
On Wed, May 7, 2008 at 11:22 PM, Jive Dadson <[EMAIL PROTECTED]> wrote: > I wonder why it does not work with > > http://stockcharts.com/webcgi/wb.exe?Data.web+SLW It looks like that is a subscription site. That makes things more complicated, because it means you'll need to figure out how to log

Re: anagram finder / dict mapping question

2008-05-08 Thread Jerry Hill
On Thu, May 8, 2008 at 7:52 PM, dave <[EMAIL PROTECTED]> wrote: > I got it! Thanks for all your help!!! Please tell me what you think: Here's yet another version of the same thing, using defaultdicts and sets. This way we don't have to test for membership in either the dictionary or the co

Re: filter in for loop

2008-08-28 Thread Jerry Hill
On Thu, Aug 28, 2008 at 6:20 AM, GHZ <[EMAIL PROTECTED]> wrote: > is there a shortcut I'm missing? Well, there's another way to do it, using the filter built in function: for filename in filter(lambda f:f.endswith('.xml'), os.listdir('.')): print filename You can do the same thing with i

Re: Tkinter on WIndows XP opens a blank screen. How can I get rid of it?

2008-10-01 Thread Jerry Hill
On Wed, Oct 1, 2008 at 5:02 PM, Chris Rebert <[EMAIL PROTECTED]> wrote: > Run your script using pythonw.exe instead of python.exe ; it doesn't open a > console window and exists for this exact purpose. In particular, you can just rename your script from "myscript.py" to "myscript.pyw". Then when

Re: Problem: neither urllib2.quote nor urllib.quote encode the unicode strings arguments

2008-10-03 Thread Jerry Hill
On Fri, Oct 3, 2008 at 5:38 PM, Valery Khamenya <[EMAIL PROTECTED]> wrote: > Hi all > things like urllib.quote(u"пиво Müller ") fail with error message: > : u'\u043f' > Similarly with urllib2. > Anyone got a hint?? I need it to form the URI containing non-ascii chars. Do you know what, exactly, yo

Re: Problem using commands.getoutput()

2009-12-08 Thread Jerry Hill
On Tue, Dec 8, 2009 at 2:31 PM, J wrote: > > So what's the point of the commands module, or is that one that only > works in Linux, and not Windows? At the very top of http://docs.python.org/library/commands.html it says "Platforms: Unix", so yes, it's Unix-only. > I can do what I want, I think,

Re: csv reader

2009-12-15 Thread Jerry Hill
On Tue, Dec 15, 2009 at 4:24 PM, Emmanuel wrote: > I have a problem with csv.reader from the library csv. I'm not able to > import accentuated caracters. For example, I'm trying to import a > simple file containing a single word "equação" using the following > code: > > import csv > arquivoCSV='te

Re: read from bin file

2009-12-17 Thread Jerry Hill
On Thu, Dec 17, 2009 at 3:59 PM, luca72 wrote: > I have a bin file that i read as: > in_file = open('primo.ske', 'rb') > leggo = luca.readlines() > > i get a list like : > ['\x00\x80p\x8b\x00\x00\x01\x19\x9b\x11\xa1\xa1\x1f\xc9\x12\xaf\x81! > \x84\x01\x00\x01\x01\x02\xff\xff\x80\x01\x03\xb0\x01\x0

Re: [ANN] pylint 0.19 / astng 0.19.2

2009-12-18 Thread Jerry Hill
On Fri, Dec 18, 2009 at 12:24 PM, Jean-Michel Pichavant >  File > "/opt/tools/python/python2.3/site-packages/logilab_astng-0.19.2-py2.5.egg/logilab/astng/infutils.py", > line 28, in >   from logilab.astng._nodes import Proxy_, List, Tuple, Function, If, > TryExcept > ImportError: No module named _

Re: list.pop(0) vs. collections.dequeue

2010-01-25 Thread Jerry Hill
On Sat, Jan 23, 2010 at 4:38 AM, Alf P. Steinbach wrote: > Hm, it would be nice if > the Python docs offered complexity (time) guarantees in general... Last time it came up, I don't think there was any core developer interest in putting complexity guarantees in the Python Language Reference. Som

Re: deriving from array.array

2010-01-26 Thread Jerry Hill
On Tue, Jan 26, 2010 at 2:28 PM, Torsten Mohr wrote: > Is there a way to find out what i need to call? I haven't found much in > the documentation. From writing C extensions i knew about the "new" entry > in the PyTypeObject struct but it seems there's more behind it. > In docs.python.org i did

Re: accessing dictionary keys

2009-10-01 Thread Jerry Hill
On Thu, Oct 1, 2009 at 4:19 PM, Andreas Balogh wrote: > Is there any shortcut which allows to use point.x with a dictionary, or > defining keys with tuples and lists? A namedtuple (introduced in python 2.6), acts like a tuple with named fields. Here's an example: >>> from collections import nam

Re: Windows file paths, again

2009-10-21 Thread Jerry Hill
On Wed, Oct 21, 2009 at 5:40 PM, Dan Guido wrote: > This doesn't give me quite the results I expected, so I'll have to > take a closer look at my project as a whole tomorrow. The test cases > clearly show the need for all the fancy parsing I'm doing on the path > though. To get back to what I thi

Re: Are *.pyd's universal?

2009-10-29 Thread Jerry Hill
On Thu, Oct 29, 2009 at 12:44 PM, Bakes wrote: > Can I use a pyd compiled on linux in a Windows distribution? No. > Or must I recompile it for windows users? Yes. -- http://mail.python.org/mailman/listinfo/python-list

Re: QuerySets in Dictionaries

2009-11-13 Thread Jerry Hill
On Fri, Nov 13, 2009 at 5:10 PM, scoopseven wrote: > I actually had a queryset that was dynamically generated, so I ended > up having to use the eval function, like this... > > d = {} > for thing in things: >query_name = 'thing_' + str(thing.id) >query_string = 'Thing.objects.filt

Re: Trouble with os.system

2010-02-03 Thread Jerry Hill
On Wed, Feb 3, 2010 at 12:58 PM, Cpa wrote: > Sure. > > import sys,re,os > files2create = sys.argv[1:] > os.system('mkdir tmp') > > # Some code to create the .tex > > # Compile tex files > os.system('for file in tmp/*; do pdflatex "$file"; done') > > Pretty simple, alas. I think your bug is in th

Re: sshd in python for windows 7

2010-02-06 Thread Jerry Hill
On Sat, Feb 6, 2010 at 7:07 PM, News123 wrote: > Hi, > > I wondered which modules would be best to perform following task: > > A user uses a standard ssh (e.g. putty or openssh) client and performs > an ssh to a windows host > > The windows host would run a python script acting as ssh server. The

Re: python crash on windows but not on linux

2010-02-11 Thread Jerry Hill
On Thu, Feb 11, 2010 at 9:32 AM, hjebbers wrote: > To all, > I am running an EDI translator, and doing stress tests. > When processing a test with a (relatively) big EDI file(s) on > windowsXP  I get a crash: >    'sorry for the inconvenience' etc  (so no clues about what is > causing the problem)

Re: What's Going on between Python and win7?

2010-02-23 Thread Jerry Hill
On Mon, Feb 22, 2010 at 8:25 PM, W. eWatson wrote: > So what's the bottom line? This link notion is completely at odds with XP, > and produces what I would call something of a mess to the unwary Python/W7 > user. Is there a simple solution? I know people went off on a tangent talking about symbol

Re: python dowload

2010-02-23 Thread Jerry Hill
On Tue, Feb 23, 2010 at 2:42 PM, monkeys paw wrote: > I used the following code to download a PDF file, but the > file was invalid after running the code, is there problem > with the write operation? > > import urllib2 > url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf' > a = open

Re: conditional import into global namespace

2010-03-02 Thread Jerry Hill
On Tue, Mar 2, 2010 at 12:46 PM, mk wrote: > Hello everyone, > > I have a class that is dependent on subprocess functionality. I would like > to make it self-contained in the sense that it would import subprocess if > it's not imported yet. > > What is the best way to proceed with this? Just impo

Re: A "scopeguard" for Python

2010-03-03 Thread Jerry Hill
On Wed, Mar 3, 2010 at 2:32 PM, Alf P. Steinbach wrote: > I'm not sure what that shows, except that you haven't grokked this yet. Maybe you could give us an example of how your code should be used, and how it differs from the other examples people have given? And maybe a quick example of why you

Re: How to run an EXE, with argument, capture output value

2010-11-19 Thread Jerry Hill
On Fri, Nov 19, 2010 at 9:52 AM, noydb wrote: > Any other help?  I am guessing not, just wanted to try one more time. > Could really use help, please!! You'll need to give us more information about the program you're trying to automate. It originally sounded like you just needed to run a console

Re: Tkinter: The good, the bad, and the ugly!

2011-01-20 Thread Jerry Hill
On Thu, Jan 20, 2011 at 4:52 PM, rantingrick wrote: >> Greg Wilson's reaction was "Yes please", and he went on to explain >> what factors kept him using Tkinter for a recent course: >        http://www.python.org/pipermail/python-dev/2000-October/016757.html > > Well that link is broken so we will

Re: numpy/matlab compatibility

2011-01-25 Thread Jerry Hill
On Tue, Jan 25, 2011 at 3:13 PM, Matt Funk wrote: > 1) a = rand(10,1) > 2) Y = a > 3) mask = Y > 100; > 4) Y(mask) = 100; > 5) a = a+Y > > Basically i am getting stuck on line 4). I was wondering if it is > possible or not with python? > (The above is working matlab code) > For those of us who d

Re: Bugs/issues in tkinter.simpledialog!!

2011-01-26 Thread Jerry Hill
On Wed, Jan 26, 2011 at 11:53 AM, rantingrick wrote: > Why would i want to waste bandwidth downloading an RC? Can i not just > browse the source online? If I understand what you're asking for, the answer is http://svn.python.org/view . If you're specifically looking for 3.2rc1, then I believe

Re: Bugs/issues in tkinter.simpledialog!!

2011-01-28 Thread Jerry Hill
On Fri, Jan 28, 2011 at 12:34 AM, rantingrick wrote: > Well i tried searching for "Tkinter" issues on the tracker and just > got annoyed quickly and left. It seems far to complicated to do > searches with this software. > You should apply some of the persistence that you show on the mailing list

Re: Bugs/issues in tkinter.simpledialog!!

2011-01-28 Thread Jerry Hill
On Fri, Jan 28, 2011 at 3:24 PM, rantingrick wrote: > Why don't you instead thank me for helping out instead of jumping to > irate conclusions? It would *seem* that if YOU cared about the future > of Python you would be more *accepting* of my help. > But you have not, in fact, helped out. You'v

Re: Style question: Nicknames for deeply nested objects

2011-01-30 Thread Jerry Hill
> > I don't. I don't expect anyone to write 10 lines of obfuscation code > when just two will suffice. Maybe you should join the perl group as > they would proud! But Stephen's 10 lines of somewhat obscure code actually works, and your two lines of code doesn't. I know which one I would prefer.

Re: How can I tell if I am inside a context manager?

2011-02-01 Thread Jerry Hill
On Tue, Feb 1, 2011 at 11:34 AM, Gerald Britton wrote: > x = open('somefile') > # return false since not in a context > with open('somefile') as x > # return true since in a context. > Perhaps something like this: x = open('somefile') if hasattr(x, '__enter__'): return false with open('somef

Re: How can I tell if I am inside a context manager?

2011-02-01 Thread Jerry Hill
On Tue, Feb 1, 2011 at 1:38 PM, Gerald Britton wrote: > As you can see, the object has a '__enter__' method regardless of how > it was created. Whatever the test, it needs to return False in the > first case and True in the second case, without modifying the class > definition. > > I'm sorry, I c

Re: Problem w/ MySQLdb

2011-02-15 Thread Jerry Hill
On Tue, Feb 15, 2011 at 3:24 PM, Victor Subervi wrote: > It builds the table but fails from the first insertion. Trying to insert > using that code directly in MySQL does indeed work. Why? In what way does it fail? Does it give you a stack trace, and if so, what does it say? Does it create the

Re: unicode shutil.copy() changes a file name during copy?

2011-02-16 Thread Jerry Hill
On Wed, Feb 16, 2011 at 1:28 PM, dave wrote: > figure it out.  it's very easy to test it yourself, just make a file > with the section symbol in it, then try to copy it with python 2.7.1 This works fine for me on Windows XP and python 2.6.4 on an NTFS formatted drive. Are either your source or d

Re: Suppress output to stdout/stderr in InteractiveInterpreter

2010-04-14 Thread Jerry Hill
On Wed, Apr 14, 2010 at 9:03 PM, Dave W. wrote: > I thought I could get away with import print_function from __future__ > (see example code below), but my re-pointed print function never gets > called. -snip- >    def __enter__(self): >        print = self.printhook That redefines the print fun

Re: csv.py sucks for Decimal

2010-04-22 Thread Jerry Hill
On Thu, Apr 22, 2010 at 8:03 PM, MRAB wrote: > It might be a stupid question, but have you tried passing in the > Decimal() object itself? MRAB's suggestion works for me in python 3.1.2: import csv, io from decimal import Decimal d = Decimal("10.00") o = io.StringIO() w = csv.writer(o, quoting=

Re: Dynamically change __del__

2010-04-30 Thread Jerry Hill
On Fri, Apr 30, 2010 at 3:16 PM, Nikolaus Rath wrote: > Apparently Python calls the class attribute __del__ rather than the > instance's __del__ attribute. Is that a bug or a feature? Is there any > way to implement the desired functionality without introducing an > additional destroy_has_been_cal

Re: long int computations

2010-05-03 Thread Jerry Hill
On Mon, May 3, 2010 at 11:17 AM, Victor Eijkhout wrote: > I have two long ints, both too long to convert to float, but their ratio > is something reasonable. How can I compute that? The obvious "(1.*x)/y" > does not work. You didn't say what version of python you were using, but this seems to wor

Re: Iterating over dict and removing some elements

2010-05-11 Thread Jerry Hill
On Tue, May 11, 2010 at 11:08 AM, Ulrich Eckhardt wrote: > My first approach was to simply postpone removing the elements, but I was > wondering if there was a more elegant solution. Iterate over something other than the actual dictionary, like this: d = {1: 'one', 2: 'two', 3: 'three'} for k i

Re: Slice last char from string without raising exception on empty string (Re: Extract all words that begin with x)

2010-05-11 Thread Jerry Hill
On Tue, May 11, 2010 at 10:37 AM, wrote: > Is there an equivalent way to slice the last char from a string (similar > to an .endswith) that doesn't raise an exception when a string is empty? If you use negative indexes in the slice, they refer to items from the end of the sequence instead of the

Re: use only files but ignore directories on Windows

2010-05-13 Thread Jerry Hill
On Thu, May 13, 2010 at 4:12 PM, albert kao wrote: > My program plan to use only files but ignore directories on Windows. > I google but do not find some functions like > bool isFile(string) > bool isDirectory(string) > Please help. You're looking for the functions os.path.isfile() and os.path.is

Re: Converting datetime.ctime() values to Unicode

2010-05-17 Thread Jerry Hill
On Mon, May 17, 2010 at 2:14 PM, wrote: > In researching a solution, I believe locale.getpreferredencoding() might > be a better choice (than locale.getdefaultlocale()[ 1 ]) for determining > a system's default encoding? I haven't used the locale module a lot, but it seems to me that if you're s

Re: function that counts...

2010-05-19 Thread Jerry Hill
On Wed, May 19, 2010 at 3:58 PM, superpollo wrote: > ... how many positive integers less than n have digits that sum up to m: ... > any suggestion for pythonizin' it? This is how I would do it: def prttn(m, n): """How many positive integers less than n have digits that sum up to m""" tot

Re: function that counts...

2010-05-19 Thread Jerry Hill
On Wed, May 19, 2010 at 4:25 PM, superpollo wrote: > Jerry Hill ha scritto: >>        sumofdigits = sum(int(char) for char in str(testval)) > > this line gives me this: > > TypeError: 'int' object is not callable > > is it some new feature in >2.5 ? No, s

Re: compile() error

2010-05-19 Thread Jerry Hill
On Wed, May 19, 2010 at 8:52 PM, Steven D'Aprano wrote: > On Wed, 19 May 2010 22:31:31 +, Benjamin Peterson wrote: >> Iuri gmail.com> writes: >>> Any ideas about what is happening? >> >> Until Python 2.7/3.2, compile() does't like sources which don't end in a >> newline. It appears to be thi

Re: strange syntax error

2010-06-04 Thread Jerry Hill
On Fri, Jun 4, 2010 at 1:31 PM, _wolf wrote: >    File "", line 6 >      # >      ^ >  SyntaxError: invalid syntax I believe you're encountering this bug: http://bugs.python.org/issue1184112 It's been fixed for 2.7 and 3.2. Until then, you'll need to work around it. You can either append a new

Re: Decimal problem

2010-06-10 Thread Jerry Hill
On Thu, Jun 10, 2010 at 3:45 PM, durumdara wrote: >from decimal import Decimal > ImportError: cannot import name Decimal > > I deleted my complete Python with all packages, and I reinstalled it. > But the problem also appeared... > > What is this? And what the hell happened in this machine th

Re: Need to import stuff

2010-08-17 Thread Jerry Hill
On Tue, Aug 17, 2010 at 6:21 PM, abhijeet thatte wrote: > Hi, > I need to import few files depending on the user input. For eg if user gives > an input as "abcd" then I will have  import "abcd.py". > Can not have any hard coding in the code. Does any one know how to solve the > problem. Use the _

Re: Unbuffered keyboard input?

2009-06-09 Thread Jerry Hill
On Tue, Jun 9, 2009 at 1:52 PM, Ken D'Ambrosio wrote: > I need to have some non-buffered keyboard interaction with a Python script > (on Linux). Assuming you're running your code from a command prompt, something like this recipe might do the trick: http://code.activestate.com/recipes/134892/ --

Re: [Mac] file copy

2009-06-23 Thread Jerry Hill
On Tue, Jun 23, 2009 at 2:28 PM, Michael Torrie wrote: > mv, cp, etc (but not rsync) are completely aware of resource forks from > Tiger on.  This is well documented and known on the Mac forums. > > So shutils should work just fine for copying, moving, etc. I don't think that's true. The shutil d

Re: Best way to add a "position" value to each item in a list

2009-07-09 Thread Jerry Hill
On Thu, Jul 9, 2009 at 4:16 PM, Sean wrote: > I have a huge list, 10,000,000+ items.  Each item is a dictionary with > fields used to sort the list.  When I have completed sorting I want to > grab a page of items, say 1,000 of them which I do easily by using > list_data[x:x+1000] > > Now I want to

Re: Einstein summation notation

2009-07-17 Thread Jerry Hill
On Fri, Jul 17, 2009 at 11:09 AM, MRAB wrote: > Python did always have True and False. Only if "always" means "since python 2.2.1". See: http://www.python.org/doc/2.3/whatsnew/section-bool.html and http://www.python.org/dev/peps/pep-0285/ for details. -- Jerry -- http://mail.python.org/mailma

Re: locale doesn' format

2009-07-20 Thread Jerry Hill
On Mon, Jul 20, 2009 at 5:07 PM, Egon Frerich wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > I want to format values to the german form eg. 1.034,56 but > locale.format() doesn't work for me. > > Here is a little test program: ... > k1 = locale.format_string('%12s',k,True) I don't th

Re: sqlite3 performance problems only in python

2009-07-23 Thread Jerry Hill
On Thu, Jul 23, 2009 at 4:29 PM, Nick Craig-Wood wrote: > In all the databases I've used, the like operator has been case > insensitive, so if that is the problem you could use This is not true in all databases!  Many times, this is something that is configurable when setting up the database serve

Re: possible to round number and convert to string?

2009-07-31 Thread Jerry Hill
On Fri, Jul 31, 2009 at 6:17 PM, Dr. Phillip M. Feldman wrote: > > I'd like to be able to convert a float to a string representation in which > the number is rounded to a specified number of digits.  If num2str is a > hypothetical function that does this, then num2str(pi,3) would be '3.142' > (not

Re: How to create functors?

2009-08-18 Thread Jerry Hill
On Tue, Aug 18, 2009 at 4:27 PM, Robert Dailey wrote: > Hello, > > I want to simply wrap a function up into an object so it can be called > with no parameters. The parameters that it would otherwise have taken > are already filled in. Like so: > > >      print1 = lambda: print( "Foobar" ) >      pr

Re: AttributeError: 'module' object has no attribute 'pack'

2009-09-10 Thread Jerry Hill
On Thu, Sep 10, 2009 at 4:21 PM, Sampsa Riikonen wrote: > Hello, > > I already solved this.. I had to set > > PYTHONPATH= > > After that the error msg disappeared. > Weird though.. I don't have any module called "subprocess" > in my personal python modules directory. You have a module named struc

Re: Use python to execute a windows program

2009-09-11 Thread Jerry Hill
On Fri, Sep 11, 2009 at 12:46 PM, Doran, Harold wrote: > I am working with this now. I'm toying with the examples to test out a > few things and learn how this works. I've made some modifications such > that I have the following working (below). This does nothing more than > open a program. > > I

Re: Use python to execute a windows program

2009-09-11 Thread Jerry Hill
On Fri, Sep 11, 2009 at 3:31 PM, Doran, Harold wrote: > Thanks, Jerry. Tried that, as well as various other possible names to no > avail. You'll need to dig into the documentation then, probably starting in one of these two places: http://pywinauto.openqa.org/howto.html http://pywinauto.openqa.or

<    1   2   3   4   >