Re: Python 3 syntax error question

2011-06-26 Thread Jerry Hill
On Sun, Jun 26, 2011 at 11:31 AM, Chris Angelico wrote: > Sure, but you don't _have_ to look at the diff. Just run it through > 2to3 and see how it runs. Never know, it might work direct out of the > box! This has been my experience, by the way. I've used a few small pure python libraries writte

Re: Significant figures calculation

2011-06-24 Thread Jerry Hill
On Fri, Jun 24, 2011 at 4:46 PM, Steven D'Aprano wrote: > Really? It works for me. > import decimal D = decimal.Decimal decimal.getcontext().prec = 2 D('32.01') + D('5.325') + D('12') > Decimal('49') I'm curious. Is there a way to get the number of significant digits for

Re: float("nan") in set or as key

2011-06-01 Thread Jerry Hill
> On Wed, Jun 1, 2011 at 1:30 PM, Carl Banks wrote: > True, but why should the "non-integer number" type be floating point > rather than (say) rational? You seem to be implying that python only provides a single non-integer numeric type. That's not true. Python ships with a bunch of different n

Re: if statement on lenght of a list

2011-05-17 Thread Jerry Hill
On Tue, May 17, 2011 at 2:02 PM, Joe Leonardo wrote: > Hey all, > > > > Totally baffled by this…maybe I need a nap. Writing a small function to > reject input that is not a list of 19 fields. > > > > def breakLine(value): > > if value.__class__() != [] and value.__len__() != 19: > > This shoul

Re: Deleting a file?

2011-05-16 Thread Jerry Hill
On Mon, May 16, 2011 at 5:23 PM, garyr wrote: > A file can be deleted by opening it with mode os.O_TEMPORARY and then > closing it. How can a file be moved to the Recycle Bin, a la Windows? I see a send2trash module (http://hg.hardcoded.net/send2trash and http://www.hardcoded.net/articles/send-fi

Re: How best to convert a string "list" to a python list

2011-05-13 Thread Jerry Hill
On Fri, May 13, 2011 at 1:15 PM, noydb wrote: > I want some code to take the items in a semi-colon-delimted string > "list" and places each in a python list.  I came up with below.  In > the name of learning how to do things properly, do you experts have a > better way of doing it? Strings have a

Re: Python program termination and exception catching

2011-04-10 Thread Jerry Hill
On Sun, Apr 10, 2011 at 3:25 PM, Jason Swails wrote: > > Hello everyone, > > This may sound like a bit of a strange desire, but I want to change the way > in which a python program quits if an exception is not caught.  The program > has many different classes of exceptions (for clarity purposes)

Re: Embedding Python: estimate size of dict/list

2011-03-28 Thread Jerry Hill
On Mon, Mar 28, 2011 at 8:26 PM, Chris Angelico wrote: > Based on the docs and http://code.activestate.com/recipes/577504/ I > understand that to be non-recursive. I'm guessing then that there > isn't a recursive version, and that it's best to recurse myself? Yes, you're right. I completely miss

Re: Embedding Python: estimate size of dict/list

2011-03-28 Thread Jerry Hill
On Mon, Mar 28, 2011 at 7:18 PM, Chris Angelico wrote: > I have an application that embeds Python to allow third-party > scripting. The Python code returns data to the application in the form > of a list or dictionary, and I'd like to have a quick check on the > size of the outputted object before

Re: embedding interactive python interpreter

2011-03-27 Thread Jerry Hill
On Sun, Mar 27, 2011 at 9:33 AM, Eric Frederich wrote: > This is behavior contradicts the documentation which says the value > passed to sys.exit will be returned from Py_Main. > Py_Main doesn't return anything, it just exits. > This is a bug. Are you sure that calling the builtin exit() function

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: 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: 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: 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: 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: 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: 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-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: 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: 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: 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: Question about expression evaluation

2010-11-08 Thread Jerry Hill
On Mon, Nov 8, 2010 at 11:17 AM, Scott Gould wrote: > --- >  File "/var/www/myproj/account/views.py", line 54, in account >    if request.account.is_instructor and request.account.contact and > request.account.contact.relationship.institution_party_number: > > AttributeError: 'NoneType' object has

Re: Trouble with importing

2010-11-02 Thread Jerry Hill
On Tue, Nov 2, 2010 at 3:33 PM, Ben Ahrens wrote: > Jerry, thanks for the reply, I was swamped with other things for the > better part of a week.. Anyway, I tried using the verbose flag when > attempting the import.  I didn't see anything that meant anything to > me, but here's the bit surrounding

Re: Trouble with importing

2010-10-26 Thread Jerry Hill
On Tue, Oct 26, 2010 at 5:24 PM, Ben wrote: > b...@sdrfid:~/gen2_rfid/trunk/src/app$ python -c "from gnuradio import > rfid" > > works fine (at least, it doesn't say anything, which I take to be a > good sign), but > > b...@sdrfid:~/gen2_rfid/trunk/src/app$ sudo python -c "from gnuradio > import r

Re: Python 2.7 parser bug on syntax for set literals ?

2010-10-23 Thread Jerry Hill
On Sun, Oct 24, 2010 at 12:40 AM, Steve Howe wrote: > Hello, > > This looks like a parser bug, but it's so basic I'm in doubt. Can > anyone confirm ? > import sys sys.version > '2.7.0+ (r27:82500, Sep 15 2010, 18:14:55) \n[GCC 4.4.5]' ({'', 1}.items()) > Traceback (most recent call

Re: Tkinter (and IDLE) window "docking?" effect when dragging root window to edge of display

2010-10-20 Thread Jerry Hill
On Wed, Oct 20, 2010 at 11:32 AM, wrote: > Python 2.6/2.7 (32-bit) for Windows: When I drag a Tkinter root window to > the left, upper, or right edge of my display ... as soon as my mouse cursor > hits the visible edge of the display ... as if I'm trying to dock the window > on the edge in questi

Re: pipe using python

2010-10-16 Thread Jerry Hill
On Sat, Oct 16, 2010 at 5:42 AM, hiral wrote: > Like we 'named pipes', how we can achieve comminication between more > than two processes. > And how it can be scaled to remote machines? > Any idea? Have you looked at the multiprocessing module? It handles communication between processes both loc

Re: Converting an ugly path to a shell path

2010-09-13 Thread Jerry Hill
On Mon, Sep 13, 2010 at 7:07 PM, wrote: > The problem that occurs now is when the user selects an "ugly" path like > this /home/user/!" §$/. > The shell don't understand the special chars so i have to escape them with > "\" . > Is there a function that does this ? http://stackoverflow.com/questi

Re: WMI in Python

2010-09-13 Thread Jerry Hill
On Mon, Sep 13, 2010 at 8:45 AM, KING LABS wrote: > Hi All, > > I am new to programming and python, Being a system administrator I > have chose Inventory (Software & Hardware ) as my first project. You'll probably want to look at the python WMI module: http://timgolden.me.uk/python/wmi/index.html

Re: Performance: sets vs dicts.

2010-08-31 Thread Jerry Hill
On Tue, Aug 31, 2010 at 10:09 AM, Aahz wrote: > I suggest that we should agree on these guarantees and document them in > the core. I can't get to the online python-dev archives from work (stupid filter!) so I can't give you a link to the archives, but the original thread that resulted in the cre

Re: Performance: sets vs dicts.

2010-08-31 Thread Jerry Hill
On Mon, Aug 30, 2010 at 7:42 PM, Aahz wrote: > Possibly; IMO, people should not need to run timeit to determine basic > algorithmic speed for standard Python datatypes. http://wiki.python.org/moin/TimeComplexity takes a stab at it. IIRC, last time this came up, there was some resistance to makin

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: [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: 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: 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: 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: 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: 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: 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: 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: Random module missing?

2009-09-23 Thread Jerry Hill
On Wed, Sep 23, 2009 at 5:00 PM, Brown, Rodrick wrote: > I seen some documentation about random.random() but my version seems to be > broken? > > Python 2.3.4 (#1, Jul 16 2009, 07:03:37) > [GCC 3.4.6 20060404 (Red Hat 3.4.6-11)] on linux2 > Type "help", "copyright", "credits" or "license" for mor

Re: detmining name during an assignment

2009-09-19 Thread Jerry Hill
On Fri, Sep 18, 2009 at 6:57 PM, Jamie Riotto wrote: > However, I'll have to keep looking for a more elegant solution. > Telling a user that typing: > cube1 = Cube(name = cube1) is a good thing because its pythonic is > somehow unsatisfying. That isn't pythonic. The usual pythonic way to map nam

Re: How to print without spaces?

2009-09-18 Thread Jerry Hill
On Fri, Sep 18, 2009 at 4:16 PM, koranthala wrote: > What if I want to print 1 to 100 in a loop without spaces in between? > I think that is the OPs question. In that case I would skip using print entirely, and use something like this: import sys for i in xrange(100): sys.stdout.write(str(i)

Re: VT100 in Python

2009-09-14 Thread Jerry Hill
On Mon, Sep 14, 2009 at 10:58 PM, bouncy...@gmail.com wrote: > From: >> http://twistedmatrix.com/documents/current/api/twisted.conch.insults.insults.ITerminalTransport.html >> http://twistedmatrix.com/documents/current/api/twisted.conch.insults.insults.ITerminalProtocol.html >> >> http://twisted

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

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: 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: 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: 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: 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: 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: 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: 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: [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: 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: 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: Collections.py -- any help?

2009-04-24 Thread Jerry Hill
On Fri, Apr 24, 2009 at 6:56 PM, Josh English wrote: > In my quest to learn more, I've been trying to get the collections.py > module to do anything but look cool. So far, it's only a cool idea. > How do they work? I can't find a tutorial on the web anywhere > explaining how I would use them in my

Re: Python not importing mysqldb

2009-04-24 Thread Jerry Hill
On Fri, Apr 24, 2009 at 4:04 PM, 83nini <83n...@gmail.com> wrote: > hi guys, > > i've been sweating the whole day trying to make python work with mysql > but in vain! > i'm doing the following: > 1. visiting http://sourceforge.net/projects/mysql-python > 2. dowloading mysql-python-test-1.2.3c1 > 3.

Re: Weird behaviour re: Python on Windows

2009-01-13 Thread Jerry Hill
On Tue, Jan 13, 2009 at 5:29 PM, Kevin Jing Qiu wrote: > I've been experiencing weird behavior of Python's os module on Windows: > > Here's the environment: > Box1: Running Windows 2003 Server with Apache+mod_python > Box2: Running Windows 2003 Server with Zope/Plone and Z:\ mapped to D:\ > on Box

Re: string split

2009-01-09 Thread Jerry Hill
On Fri, Jan 9, 2009 at 3:39 PM, Benjamin Kaplan > This looks like a CSV file to me. If that is the case, it is easier to use > the built-in csv module than to try to write your own parser. It should be as easy as this: import csv testfile = open('testfile.csv', 'w') testdata = """100-01001-001,"

Re: Equivalent of 'wget' for python?

2008-12-08 Thread Jerry Hill
On Mon, Dec 8, 2008 at 11:53 AM, r0g <[EMAIL PROTECTED]> wrote: > urllib.urlretrieve(url_of_zip_file, destination_on_local_filesystem). In python 3.0, that appears to be: import urllib.request urllib.request.urlretrieve(url, local_file_name) -- Jerry -- http://mail.python.org/mailman/listinfo/p

Re: Python 3 read() function

2008-12-04 Thread Jerry Hill
On Thu, Dec 4, 2008 at 11:48 AM, Christian Heimes <[EMAIL PROTECTED]> wrote: > Cro wrote: >> vContent = io.StringIO() >> vContent = huge.read() # This line takes hours to process !!! > > Do you really mean io.StringIO? I guess you want io.BytesIO() .. I don't think it matters. Here's a quick comp

Re: help me~!about base64

2008-12-02 Thread Jerry Hill
On Tue, Dec 2, 2008 at 2:08 PM, <[EMAIL PROTECTED]> wrote: print base64.__file__ > /usr/lib/python2.5/base64.pyc That looks fine, and matches what I have on my linux box. Your code works fine for me when I run it, so I'm out of ideas. -- Jerry -- http://mail.python.org/mailman/listinfo/pyt

Re: help me~!about base64

2008-12-02 Thread Jerry Hill
2008/12/2 <[EMAIL PROTECTED]>: > it's run ,Eric gave me error,the error is "'module' object has no > attribute 'decodestring'", Do you have your own base64.py (or base64.pyc) that's shadowing the standard module base64? Try this: >>> import base64 >>> print base64.__file__ C:\Python25\lib\base6

Re: Checking a string against multiple matches

2008-12-01 Thread Jerry Hill
On Mon, Dec 1, 2008 at 3:29 PM, Aaron Scott <[EMAIL PROTECTED]> wrote: > Damn you, Python, and your loose documentation! It never occurred to > me to actually TRY my pseudocode, since I couldn't find anything on > that type of statement. Anyway, feel free to ignore me from now on. I'm not sure whe

Re: Checking a string against multiple matches

2008-12-01 Thread Jerry Hill
On Mon, Dec 1, 2008 at 2:31 PM, Aaron Scott <[EMAIL PROTECTED]> wrote: > Pseudocode: > > if "two" in ["one", "two", "three", "four"]: > return True That works, just like you wrote it: >>> "two" in ["one", "two", "three", "four"] True >>> "two" in ["one", "twofer", "three", "four"] False If

Re: Unicode regex and Hindi language

2008-11-28 Thread Jerry Hill
On Fri, Nov 28, 2008 at 10:47 AM, Shiao <[EMAIL PROTECTED]> wrote: > The regex below identifies words in all languages I tested, but not in > Hindi: > > # -*- coding: utf-8 -*- > > import re > pat = re.compile('^(\w+)$', re.U) > langs = ('English', '中文', 'हिन्दी') I think the problem is that the H

Re: 404 not found on for Python 2.6 Itanium

2008-11-19 Thread Jerry Hill
On Wed, Nov 19, 2008 at 4:12 PM, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: >> Then why is there a link on the download site? > > Where specifically did you spot that link? I can't see any. I believe the link in question is on the page http://www.python.org/download/ titled "Python 2.6 Windows I

Re: segfault matplotlib with Python2.6

2008-11-17 Thread Jerry Hill
On Mon, Nov 17, 2008 at 5:58 PM, Magdoll <[EMAIL PROTECTED]> wrote: > Has anyone run into the same problem I have? I used to run matplotlib > with Python2.5 and everything worked fine. Now I use Python2.6, and > everything falls apart. > > I installed numpy, libpng, and freetype as required by matp

Re: regular expressions ... slow

2008-11-17 Thread Jerry Hill
On Mon, Nov 17, 2008 at 4:37 PM, Uwe Schmitt <[EMAIL PROTECTED]> wrote: > Hi, > > Is anobody aware of this post: http://swtch.com/~rsc/regexp/regexp1.html ? Yes, it's been brought up here, on python-dev and python-ideas several times in the past year and a half. > Are there any plans to speed u

Re: object creation

2008-11-14 Thread Jerry Hill
On Fri, Nov 14, 2008 at 6:38 PM, Joe Strout <[EMAIL PROTECTED]> wrote: > On Nov 14, 2008, at 4:33 PM, Jerry Hill wrote: > >> Then add >> def __init__(self): >> a = 0 >> b = 0 > > Doesn't that have to be "self.a" and "self.b"?

Re: object creation

2008-11-14 Thread Jerry Hill
On Fri, Nov 14, 2008 at 6:10 PM, BiraRai <[EMAIL PROTECTED]> wrote: > class box: > a = int() > b = int() > > def createSomething(self,x): At a guess, x = box() does create a new instance of your box class, but since you've declared a and b to be class variables instead of instance variables,

Re: Sync paramstyle between sqlite and mysql

2008-11-11 Thread Jerry Hill
On Mon, Nov 10, 2008 at 1:00 PM, Daniel <[EMAIL PROTECTED]> wrote: > I have read in PEP249 (http://www.python.org/dev/peps/pep-0249/) that > there are five paramstyles, though it wasn't clear if I should expect > these to be implemented in all DBAPI2 compliant modules. I have found > that I can se

Re: Problem using urllib to download images

2008-11-03 Thread Jerry Hill
On Mon, Nov 3, 2008 at 2:21 PM, <[EMAIL PROTECTED]> wrote: > Then perhaps it's a problem with my os. > [TERMINAL SESSION] > [18:16:33 Mon Nov 03] python > Python 2.6 (trunk:66714:66715M, Oct 1 2008, 18:36:04) > [GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin > Type "help", "copyright", "c

Re: Python/Numeric users be aware!

2008-10-29 Thread Jerry Hill
On Wed, Oct 29, 2008 at 1:53 PM, Benyang <[EMAIL PROTECTED]> wrote: > The Python version is 2.5.1, and Numeric is the latest version 24.2. While 24.2 is the latest version of Numeric, it's also three years old and no longer supported. From http://numpy.scipy.org/ - "Numeric was the first arrayobj

Re: portable python

2008-10-24 Thread Jerry Hill
On Fri, Oct 24, 2008 at 2:33 PM, asit <[EMAIL PROTECTED]> wrote: > this the o/p > [EMAIL PROTECTED]:~/hack$ python portscan.py 59.93.128.10 10 20 > Traceback (most recent call last): > File "portscan.py", line 33, in >print str(port) + " : " + scan(ip,port,timeout) > File "portscan.py", line

Re: portable python

2008-10-24 Thread Jerry Hill
On Fri, Oct 24, 2008 at 1:42 PM, asit <[EMAIL PROTECTED]> wrote: > I code in both windows and Linux. As python is portable, the o/p > should be same in both cases. But why the following code is perfect in > windows but error one in Linux ??? What error message do you get in linux? How are you r

Re: Unicode (UTF8) in dbhas on 2.5

2008-10-21 Thread Jerry Hill
On Tue, Oct 21, 2008 at 10:16 AM, Yves Dorfsman <[EMAIL PROTECTED]> wrote: > My terminal is setup in UTF-8, and... It did print correctly. I expected > that by setting coding: utf-8, all the I/O functions would do the encoding > for me, because if they don't then I, and everybody who writes a scrip

<    1   2   3   4   >