Re: A "scopeguard" for Python

2010-03-03 Thread Jerry Hill
xample of why you would not want to clean up after a failed operation? I've been trying to follow along, and I don't get it either. I guess that makes me at least the third person that doesn't understand what you're trying to get across. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

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

2010-11-19 Thread Jerry Hill
simple GUI automation with pywinauto. The homepage appears to be: http://pywinauto.pbworks.com which has installation instructions and a FAQ. You might also find this demo useful: http://showmedo.com/videotutorials/video?name=UsingpyWinAutoToControlAWindowsApplication -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

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

2011-01-20 Thread Jerry Hill
> Well that link is broken so we will never know what greg said? I think that's referring to this email: http://mail.python.org/pipermail/python-dev/2000-October/010046.html -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: numpy/matlab compatibility

2011-01-25 Thread Jerry Hill
b code) > For those of us who don't know Matlab, what does that code do? -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Bugs/issues in tkinter.simpledialog!!

2011-01-26 Thread Jerry Hill
.org/view/python/tags/r32rc1/Lib/tkinter/simpledialog.py?view=markup -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Bugs/issues in tkinter.simpledialog!!

2011-01-28 Thread Jerry Hill
ou show on the mailing list to the problem! Go to http://bugs.python.org On the left hand side, there's a link to the search page (listed just below "Issues"). Click that. Find the list box labeled "Components" and select "Tkinter" from the drop down. Click Search

Re: Bugs/issues in tkinter.simpledialog!!

2011-01-28 Thread Jerry Hill
really isn't difficult, but you don't seem to be willing to do it. Until you do, all you're doing is ranting, not helping. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Style question: Nicknames for deeply nested objects

2011-01-30 Thread Jerry Hill
I know which one I would prefer. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

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

2011-02-01 Thread Jerry Hill
r(x, '__enter__'): return false with open('somefile') as x: do_something() -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

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

2011-02-01 Thread Jerry Hill
tion. > > I'm sorry, I completely misunderstood your question. I thought you were asking how you could tell if something provided a context manager. Based on the PEP[1], I don't see any generic way to tell if you are within a context manager. 1: http://www.python.org/

Re: Problem w/ MySQLdb

2011-02-15 Thread Jerry Hill
te the table, but not populate any data? If that's the case, you probably need to call commit() after you do your inserts. I'm not familiar with the MySQLDB module in particular, but python database adapters typically do not autocommit, unless you explicitly ask for that behavior. --

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

2011-02-16 Thread Jerry Hill
r source or destination network drives? What does sys.getfilesystemencoding() say the encoding of your filesystem is? -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

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
csv.writer(o, quoting=csv.QUOTE_NONNUMERIC) w.writerow([10, 10.00, d, "10"]) print(o.getvalue()) >>> 10,10.0,10.00,"10" That's an int, a float, a Decimal and a string, all of which appear to be formatted as I would expect. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamically change __del__

2010-04-30 Thread Jerry Hill
n > additional destroy_has_been_called attribute? It's a documented feature: http://docs.python.org/reference/datamodel.html#new-style-special-lookup I'm not aware of a way to get around it, so I think you'll need to fall back to checking a flag in the class's __del__ method. -- Jerry -- ht

Re: long int computations

2010-05-03 Thread Jerry Hill
ite a few python versions (since 2.2 maybe?), and has become the default in python 3. If you need to do integer division, you would use the // operator: >>> long1 // long2 0L Hope that helps. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterating over dict and removing some elements

2010-05-11 Thread Jerry Hill
', 3: 'three'} for k in d.keys(): if d[k] == 'two': d.pop(k) -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

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
instead of the front. So slicing the last character from the string would be: word[-1:] -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: use only files but ignore directories on Windows

2010-05-13 Thread Jerry Hill
os.path.isfile() and os.path.isdir() See http://docs.python.org/library/os.path.html for details. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting datetime.ctime() values to Unicode

2010-05-17 Thread Jerry Hill
o me that if you're setting the locale with locale.setlocale(), you should get the encoding from locale.getlocale()[1]. You're not really interested in the system's default encoding at this point, you're interested in the encoding of the locale you've explicitly set.

Re: function that counts...

2010-05-19 Thread Jerry Hill
supposed to represent. I also moved the convert-to-string-and-sum-the-digits logic into a single generator expression that's passed to the builtin sum function. Oh, and I tried to use slightly more expressive variable names. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

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
ow the full > context, but it seems to me that compile can deal with the lack of > newline. The original example was: compile("for i in [1,2,3]:\n pass\n#end", "test_file.py", "exec") Bug 1184112 is only triggered with an indented block followed by a comment with no newline following the comment. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: strange syntax error

2010-06-04 Thread Jerry Hill
k around it. You can either append a newline to the end of any source snippets that you are exec-ing, or if you're writing the code snippets that are being exec-ed yourself, don't write them in such a way that they trigger the bug. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Decimal problem

2010-06-10 Thread Jerry Hill
pened in this machine that > destroyed my working python apps...? > My guess is that you have a file named decimal.py (and/or decimal.pyc) in your working directory, which is shadowing the standard library's decimal module. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

From Dict to Classes yes or no and how

2010-06-22 Thread Jerry Rocteur
or call up individual items from the class, for example: print users['jro']['name'], users['jro']['secnum'], users['jro']['groups'] or for keys in users: print users[keys]['name'] for group in users[keys]['groups']: print group etc. Thanks in advance, jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: From Dict to Classes yes or no and how

2010-06-22 Thread Jerry Rocteur
> On 06/22/2010 12:05 PM, Jerry Rocteur wrote: >> Sorry for the long mail but I've been searching the web for days for how to >> do this.. I see that possibilities using >> shelve or pickle but I don't want to do this (The source of the data changes >> const

Re: From Dict to Classes yes or no and how

2010-06-22 Thread Jerry Rocteur
> -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 06/22/2010 01:32 PM, Jerry Rocteur wrote: >> My input is NOT CSV, I used this format to try and make the question >> shorter. Although I could create a CSV file, >> I'd >> like to learn how to code a

Second attempt WAS: From Dict to Classes yes or no and how

2010-06-22 Thread Jerry Rocteur
> On Tue, Jun 22, 2010 at 9:32 PM, Jerry Rocteur wrote: > If you were able to ask us perhaps a more specific question > and describe your problem a little more concisely perhaps > I (and we) might have a bit more to offer you. I have a dictionary: users[key] = {'u

Second attempt WAS: From Dict to Classes yes or no and how

2010-06-22 Thread Jerry Rocteur
> On Tue, Jun 22, 2010 at 9:32 PM, Jerry Rocteur wrote: > If you were able to ask us perhaps a more specific question > and describe your problem a little more concisely perhaps > I (and we) might have a bit more to offer you. I have a dictionary: users[key] = {'u

Second attempt WAS: From Dict to Classes yes or no and how

2010-06-22 Thread Jerry Rocteur
> On Tue, Jun 22, 2010 at 9:32 PM, Jerry Rocteur wrote: > If you were able to ask us perhaps a more specific question > and describe your problem a little more concisely perhaps > I (and we) might have a bit more to offer you. I have a dictionary: users[key] = {'u

Second attempt WAS: From Dict to Classes yes or no and how

2010-06-22 Thread Jerry Rocteur
> On Tue, Jun 22, 2010 at 9:32 PM, Jerry Rocteur wrote: > If you were able to ask us perhaps a more specific question > and describe your problem a little more concisely perhaps > I (and we) might have a bit more to offer you. I have a dictionary: users[key] = {'u

Re: Python as a scripting language. Alternative to bash script?

2010-07-02 Thread Jerry Rocteur
ted. > > Take a look at Python for Unix and Linux System Administration: http://www.amazon.com/Python-Unix-Linux-System-Administration/dp/0596515820 I quite like the book, I learned about Ipython from this book and I'm quite glad I did! Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Need to import stuff

2010-08-17 Thread Jerry Hill
to solve the > problem. Use the __import__ function ( http://docs.python.org/library/functions.html#__import__ ), like this: user_module = __import__("abdc") user_module.do_stuff() -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Unbuffered keyboard input?

2009-06-09 Thread Jerry Hill
m/recipes/134892/ -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: [Mac] file copy

2009-06-23 Thread Jerry Hill
question from the first email in this thread, that should pretty strongly warn you that shutil.copy2 is not going to do what you want. Not being a mac user myself, I don't know what the right way to accomplish what you want is, though. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

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

2009-07-09 Thread Jerry Hill
e a for loop, like this: for idx,item in enumerate(my_list_of_dicts): item['position'] = idx Is there a particular reason you want to do this with a list comprehension? Using a list comp means you're going to create an extra copy of your 10 million item list, just so you can ad

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 --

Re: locale doesn' format

2009-07-20 Thread Jerry Hill
ting function, and I don't think that floats (or Decimal.Decimal objects) take locale into account when you do that. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: sqlite3 performance problems only in python

2009-07-23 Thread Jerry Hill
he database server.  I'm not sure what the defaults are, but here at work we have DB/2 and Oracle servers that are case sensitive, and at least one MSSQL server that is not. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: possible to round number and convert to string?

2009-07-31 Thread Jerry Hill
/docs.python.org/library/stdtypes.html#string-formatting ) For example: >>> from math import pi >>> pi 3.1415926535897931 >>> "%0.3f" % pi '3.142' If you need it as a function, you could do something like this: >>> def num2str(num, precision)

Re: How to create functors?

2009-08-18 Thread Jerry Hill
e first part of your message, you might find something of use in the functools module, particularly functools.partial [3]. 1: http://docs.python.org/tutorial/controlflow.html#lambda-forms 2: http://docs.python.org/reference/simple_stmts.html 3: http://docs.python.org/library/functools.html#functools.partial -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

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

2009-09-10 Thread Jerry Hill
odules directory. You have a module named struct.py (or strucy.pyc) that is shadowing the builtin struct module. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Use python to execute a windows program

2009-09-11 Thread Jerry Hill
?? Doesn't seem to work. I'm not very familiar with pywinauto myself, but a quick look through the docs says that the application looks for a window or dialog with a "similar" name to what you put there. So, what does the title bar of the window opened by AM.exe say

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/howt

Re: VT100 in Python

2009-09-14 Thread Jerry Hill
tml >> >> http://twistedmatrix.com/projects/conch/documentation/examples/ (the >> insults section) > > what`s with all the `insult` strings? - gimmick? I think that 'insults' is twisted's replacement for curses. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: How to print without spaces?

2009-09-18 Thread Jerry Hill
(str(i)) sys.stdout.write('\n') That allows you to bypass any of the behavior of the print builtin that you don't want. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: detmining name during an assignment

2009-09-19 Thread Jerry Hill
ternal dictionary of all of the objects in the scene. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Random module missing?

2009-09-23 Thread Jerry Hill
l last): >  File "", line 1, in ? > AttributeError: 'module' object has no attribute 'rand > > Please advise thanks. You have a file named random.py (and/or random.pyc) that is shadowing the built in module. Rename it. if you have trouble finding it, you can do the following: import random print random.__file__ -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Performance: sets vs dicts.

2010-08-31 Thread Jerry Hill
nce to making promises about time complexity in the official docs, since that would make those numbers part of the language, and thus binding on other implementations. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Performance: sets vs dicts.

2010-08-31 Thread Jerry Hill
ubject, so maybe it's something that would be worth revisiting, assuming someone wants to write the doc change. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

sqlalchemy: how to define association object with declarative style?

2010-09-07 Thread Jerry Fleming
Hi, I want to define the relationship for my users and their groups with declarative style (so that the relating model can inherit Timestamp mixin and Tablename mixin): class User(DeclarativeBase, Tablename, TimestampMixin): '''User avatar is named after its id. A user may be a student or

Re: WMI in Python

2010-09-13 Thread Jerry Hill
lden.me.uk/python/wmi/index.html as well as the pywin32 module: http://sourceforge.net/projects/pywin32/ IIRC, there's been quite a bit of discussion about inventorying installed software on the pywin32 mailing list: http://mail.python.org/mailman/listinfo/python-win32 -- Jerry -- http://mail.p

Re: Converting an ugly path to a shell path

2010-09-13 Thread Jerry Hill
on that does this ? http://stackoverflow.com/questions/35817/whats-the-best-way-to-escape-ossystem-calls-in-python seems to cover most of the possibilities. Particularly, do you really need shell=True? If not, you can just call Popen([command, path], stdout=PIPE, stderr=PIPE) and not worry about it.

re and locale/unicode

2010-09-20 Thread Jerry Fleming
Hi, Having the following python code: import locale import re locale.setlocale(locale.LC_ALL, 'zh_CN.utf8') re.findall('(?uL)\s+', u'\u2001\u3000\x20', re.U|re.L) re.findall('\s+', u'\u2001\u3000\x20', re.U|re.L) re.findall('(?uL)\s+', u'\u2001\u3000\x20') I was wondering why doesn't it find

Re: pipe using python

2010-10-16 Thread Jerry Hill
between processes both locally and remotely, with an interface very similar to the threading module. http://docs.python.org/library/multiprocessing.html Or perhaps pyro? http://www.xs4all.nl/~irmen/pyro3/manual/1-intro.html -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

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

2010-10-20 Thread Jerry Hill
able to override how your application responds to those messages to dock the way you want to. It'll probably take some experimentation, though. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

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

2010-10-23 Thread Jerry Hill
.5]' >>>> ({'', 1}.items()) > Traceback (most recent call last): >  File "", line 1, in > AttributeError: 'set' object has no attribute 'items' I don't see anything in the docs that indicates that set objects have a .items()

Re: Trouble with importing

2010-10-26 Thread Jerry Hill
h -v or -vv? Like this: sudo python -v -c "from gnuradio import rfid -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

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, b

Re: Question about expression evaluation

2010-11-08 Thread Jerry Hill
buteError: 'NoneType' object has no attribute 'relationship' > --- > > I'm leaving out all the supporting code deliberately. Perhaps request.account is being mutated in another thread? -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Two variable dictionary comprehension

2017-04-03 Thread Jerry Hill
search results, Google does a fine job of answering python questions, at least when you already know the key phrase to look for. -- Jerry -- https://mail.python.org/mailman/listinfo/python-list

Re: Two variable dictionary comprehension

2017-04-03 Thread Jerry Hill
thing to end up mixed in with the desired results. It goes on in that vein out to page 11 or so, at which point things seem to devolve a bit. I'd be totally sympathetic with your plight if you didn't know the key phrase 'dict comprehension' to find all of that information. I&#x

Re: how to write add frequency in particular file by reading a csv file and then making a new file of multiple csv file by adding frequency

2017-06-27 Thread Jerry Hill
efaultdict frequency = defaultdict(int) ... ... if word1 == word: frequency[word] += 1 The defaultdict takes care of the special case for you. If the value is missing, it's defaulted to 0. -- Jerry -- https://mail.python.org/mailman/listinfo/python-list

Re: If you are running 32-bit 3.6 on Windows, please test this

2017-08-30 Thread Jerry Hill
uot;, "copyright", "credits" or "license" for more information. > >>> import math > >>> math.sqrt(1.3) > 1.140175425099138 > >>> > > This is on 64-bit Windows 10. > -- > https://mail.python.org/mailman/listinfo/python-list

Re: VIM editor question

2007-06-09 Thread Jerry Van Brimmer
On 6/9/07, BartlebyScrivener <[EMAIL PROTECTED]> wrote: > On Jun 9, 1:14 am, "Jerry VanBrimmer" <[EMAIL PROTECTED]> wrote: > > > In your vim configuration file enter: > > > > colorscheme > > > > Example: > > > > colorscheme el

math module for Decimals

2008-12-27 Thread jerry . carl . mi
lex things? Any recommendations? Or am I completely missing something? (2) Is there any plan to provide a standard python module that would do that? (Python 4.0? ;-) Thanks for your comments and help, Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: math module for Decimals

2008-12-27 Thread jerry . carl . mi
> Which math functions? ln, log10, exp, sqrt already exist as methods of   > Decimal instances. At the end of the Decimal docs there are a few   > examples, including computing sin and cos (but apparently they naïvely use   > a McLaurin series like you noticed in other module). Hi Gabriel - than

Re: math module for Decimals

2008-12-28 Thread jerry . carl . mi
Hi Steven... thanks for your kind and extensive reply. Lots of good food for thought. I know it's easy to complain about lack of functionality, but it really was not my intention. Python is very cool as it is and I still know too little about it to even suggest anything. I just thought maybe I was

Re: math module for Decimals

2008-12-28 Thread jerry . carl . mi
> - are you using Decimal for the base-10-ness or the >   extra precision Decimal provides?  Or significant zeros? >   Or compatibility with existing Decimal code, or what? Oh boy, now I will finally prove myself illiterate... well, so be it. But i am after the extra precision: >>> from math imp

Re: math module for Decimals

2008-12-28 Thread jerry . carl . mi
> 1. mpmath? > 2. sympy? > 3. Sage? Haven't tried those, i guess i have some studying to do. > > > x=Decimal.__mod__(x,Decimal('2')*pi()) > > > Works fine for what i need, but i am sure it's not the right way to do > > it. > > I don't know of any better way to deal with large arguments. > The m

Re: math module for Decimals

2008-12-28 Thread jerry . carl . mi
mpmath... wow... just did what i needed :-) Thanks, Mark! Hopefully i did not waste too much of your time... and perhaps this discussion will send other lost sheeps in the right direction. (Still, it would make sense to have the goniometric functions in decimal.) -- http://mail.python.org/mai

<    1   2   3   4   5