Re: __hash__ and ordered vs. unordered collections

2017-11-21 Thread Josh B.
http://bidict.rtfd.io>. Feedback always welcome. Thanks, Josh -- Forwarded message -- From: Raymond Hettinger Date: Mon, Nov 20, 2017 at 4:46 PM Subject: Re: __hash__ and ordered vs. unordered collections To: j...@math.brown.edu If you want to make ordered and unordered coll

Re: __hash__ and ordered vs. unordered collections

2017-11-20 Thread Josh B.
On Monday, November 20, 2017 at 2:31:40 PM UTC-5, MRAB wrote: > What if there are duplicate elements? > > Should that be MyColl(some_elements) == MyOrderedColl(other_elements) > iff len(some_elements) == len(other_elements) and set(some_elements) == > set(other_elements)? Yes, that's what I mea

Re: __hash__ and ordered vs. unordered collections

2017-11-20 Thread Josh B.
On Monday, November 20, 2017 at 1:55:26 PM UTC-5, Chris Angelico wrote: > But what you have is the strangeness of non-transitive equality, which > is likely to cause problems. But this is exactly how Python's built-in dict and OrderedDict behave: >>> od = OrderedDict([(1, 0), (2, 0), (3, 0)]) >>>

__hash__ and ordered vs. unordered collections

2017-11-20 Thread Josh B.
ot;, but to be clear, I think this behavior is totally right. However, I'm less confident that this kind of behavior is useful for MyColl and MyOrderedColl. Could anyone who feels more certain one way or the other please explain the rationale and possibly even give some real-world examples? Thanks! Josh -- https://mail.python.org/mailman/listinfo/python-list

Windows alternative: multiprocessing.connection.wait on Pipe, Tkinter File Handlers

2017-10-23 Thread Josh Jacobson
The two functions in the subject are not fully implementable on Windows, and so I am looking for an alternative. Relevant SO postings including full code and description, with bounty: Freezes

Re: Mysterious Logging Handlers

2016-09-12 Thread Josh English
On Friday, September 9, 2016 at 11:31:13 AM UTC-7, Peter Otten wrote: > Josh English wrote: > > > > > LOG = logging.getLogger('SHIPPING') > > FORMAT = '%(asctime)-15s %(name)s %(level)-8s %(message)s' > > That should be either levelname or

Re: Mysterious Logging Handlers

2016-09-12 Thread Josh English
On Friday, September 9, 2016 at 11:29:32 AM UTC-7, John Gordon wrote: > In <247db0ab-efe7-484b-a418-dd219f68a...@googlegroups.com> Josh English > writes: > > > When I run the scriptI get logging information from only xlreader, not > > from the main script: > >

Mysterious Logging Handlers

2016-09-09 Thread Josh English
ER.handlers >>> [] >>> XLOGGER.debug('test') >>> DEBUG:XLREADER:test >>> LOG.handlers >>> [, ] >>> [h.formatter._fmt for h in LOG.handlers] >>> ['%(asctime)-15s %(name)s %(level)-8s %(message)s', '%(asctime)-15s %(name)s %(level)-8s %(message)s'] How can I track where this formatting is coming from? Josh -- https://mail.python.org/mailman/listinfo/python-list

Best Practices for Internal Package Structure

2016-04-04 Thread Josh B.
ably do it anyway in order to really explicit about what the public API is. """ Curious what folks on this list recommend, or if there are best practices about this published somewhere. Thanks, Josh -- https://mail.python.org/mailman/listinfo/python-list

Re: Most pythonic way of rotating a circular list to a canonical point

2015-08-01 Thread Josh English
examples all look like sorting to me. I think the collections.deque object has a rotate method, and rotating through the possibilities looking for matches may work, or take any deque, rotate so the minimum value is at the first place in the deque, and then compare. Or am I not understanding what you mean? Josh -- https://mail.python.org/mailman/listinfo/python-list

Re: Google Code Shutting Down

2015-03-13 Thread Josh English
Thanks for the discussion. I found my original concern was supposedly about sourceforge. PyPi, according to a post over on pypubsub-dev that pip installs had anecdotal problems with sourcforge-hosted projects. I guess I wanted some more anecdotes and opinions before I tried moving anything. I

Google Code Shutting Down

2015-03-12 Thread Josh English
I've been hosting Python projects on Google Code, and they're shutting down. Damn. What is the recommended replacement for Code Hosting that works reliably with PyPi and pip? -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a way to schedule my script?

2014-12-18 Thread Josh English
On Wednesday, December 17, 2014 11:11:11 AM UTC-8, Juan Christian wrote: > I know about the schedule modules and such but they work in situations like > 'run this in a X hours/minutes/seconds interval', I already have my code in a > while loop with sleep (it's a bit ugly, I'l change to a schedule

Re: protocol.py, brine.py, and compat.py causing trouble

2014-09-15 Thread Josh English
On Sunday, September 14, 2014 10:59:07 AM UTC-7, Terry Reedy wrote: > On 9/14/2014 2:44 AM, Josh English wrote: > > > To the best of my knowledge, protocol.py, brine.py, compat.py, are not > part of the stdlib. What have you installed other than Python? What > editor/IDE are

Re: protocol.py, brine.py, and compat.py causing trouble

2014-09-15 Thread Josh English
out to be part of PyScripter, my IDE. Oddly enough, once I fixed the actual problem (minutes after posting) it still makes no sense... I had a list of things that I processed and returned, but some refactoring left out filling the return list with anything. I'm not sure what h

Re: Storing instances using jsonpickle

2014-09-15 Thread Josh English
#x27;s __dict__ is serializable, but that's not so tough. I need to add a version number, though. Good idea, that. Josh -- https://mail.python.org/mailman/listinfo/python-list

protocol.py, brine.py, and compat.py causing trouble

2014-09-13 Thread Josh English
s is where I managed to send a keybord interrupt. I was working just fine, tweaking a line, running the code, tweaking a line, running the code, until this point. I'm on Windows 7 using Python 2.7.5. I should upgrade, and will do so, but what are these files and why are they suddenly crashi

Re: Storing instances using jsonpickle

2014-09-03 Thread Josh English
cade trying to make an XML-based database work, in part because of this limitation. Some days I get so frustrated I think the only data structure I should ever use is a dictionary. I suppose to make this sort of thing work, I should look at creating custom json encoders and decoders.

Storing instances using jsonpickle

2014-09-03 Thread Josh English
I am using jsonpickle to store instances of an object into separate data files. If I make any changes to the original class definition of the object, when I recreate my stored instances, they are recreated using the original class definition, so any new attributes, methods, or properties, are lo

Re: os.startfile hanging onto the launched app, or my IDE?

2014-06-09 Thread Josh English
access the file (because it is currently open). I even left it open and ran another script that also creates and launches an Excel workbook, and it again did not close Excel. So this quirk is coming from PyScripter, which is a shame, because I don't think it's under development, so it won't be fixed. Josh -- https://mail.python.org/mailman/listinfo/python-list

os.startfile hanging onto the launched app, or my IDE?

2014-06-06 Thread Josh English
DE is keeping track of things created by the os.startfile call, but the docs imply this doesn't happen. Is this a quirk of os.startfile? Is there a cleaner way to get Windows to open files without tying back to my program? Thanks, Josh -- https://mail.python.org/mailman/listinfo/python-list

Re: Yet another "simple" headscratcher

2014-05-30 Thread Josh English
Mea culpa, gang. I found it. It had absolutely nothing to do with the multiplication. It was in zero_matrix. I feel like a fool. Josh -- https://mail.python.org/mailman/listinfo/python-list

Yet another "simple" headscratcher

2014-05-30 Thread Josh English
em in a particular row is assigning the same row values to every row. This should be one of those really simple Python things, but for the life of me I don't see it. The first [[4, 0], [4, 0]] is clearly wrong. In each step, this algorithm is repeating the row. Any ideas as to why this is happening? Python 2.7.5, Windows 7, so nothing exotic. Josh -- https://mail.python.org/mailman/listinfo/python-list

Re: [ANNC] pybotwar-0.9 : now using pybox2d-2.3b0

2014-05-06 Thread Josh English
I loved RoboWar on my Mac, many ages ago. I wrote a Stack based language very similar to the one RoboWar used. If you're interested, let me know. Josh English On Saturday, May 3, 2014 3:28:34 PM UTC-7, Lee Harr wrote: > pybotwar is a fun and educational game where players > wri

Re: Keeping track of things with dictionaries

2014-04-07 Thread Josh English
On Monday, April 7, 2014 9:08:23 PM UTC-7, Chris Angelico wrote: > That depends on whether calling Brand() unnecessarily is a problem. > Using setdefault() is handy when you're working with a simple list or > something, but if calling Brand() is costly, or (worse) if it has side > effects that you

Re: Keeping track of things with dictionaries

2014-04-07 Thread Josh English
On Sunday, April 6, 2014 12:44:13 AM UTC-7, Giuliano Bertoletti wrote: > obj = brands_seen.get(brandname) > > if obj is None: > obj = Brand() > brands_seen[brandname] = obj > > Would dict.setdefault() solve this problem? Is there any advantage to defaultdict ov

Re: Switching between cmd.CMD instances

2014-04-03 Thread Josh English
d('submission {}'.format(line)) return True Boss = BossCmd() Sub = SubmissionCmd(Boss) Story = StoryCmd(Boss) Boss.cmdloop() This gives me a flexible framework to bounce between Cmd instances at will, and quit the program from anywhere. Josh -- https://mail.python.org/mailman/listinfo/python-list

Switching between cmd.CMD instances

2014-04-01 Thread Josh English
tween them. Exiting either of the sub-command objects returns back to the BossCmd. I have defined both a do_done and do_exit method on the sub-commands. Is it possible to flag BossCmd so when either of the other two process do_exit, the BossCmd will also exit? Josh -- https://mail.pytho

Re: Oddity using sorted with key

2014-03-11 Thread Josh English
On Tuesday, March 11, 2014 9:25:29 AM UTC-7, John Gordon wrote: > > > > > Why do you say that 'key=lambda x: x.name.lower' is the correct form? That > > returns the str.lower() function object, which is a silly thing to sort > > on. Surely you want to sort on the *result* of that function, w

Re: Oddity using sorted with key

2014-03-11 Thread Josh English
A comprehensive and educational answer, Peter. Thank you. Josh -- https://mail.python.org/mailman/listinfo/python-list

Oddity using sorted with key

2014-03-11 Thread Josh English
sort properly. Any ideas why I'm seeing two different results? Especially as the correct form is giving me the wrong results? Josh English -- https://mail.python.org/mailman/listinfo/python-list

Re: Understanding how is a function evaluated using recursion

2013-09-25 Thread Josh English
ted, what value does it returns? > In this case, flatten always returns a list. When it hits the recursion, it calls itself to get another list, that it uses to extend the current list. Josh -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a function that applies list of functions to a value?

2013-08-28 Thread Josh English
Reduce tricks are nice, but I prefer clarity sometimes: def double(x): return x*2 def add3(x): return x+3 def compose(*funcs): for func in funcs: if not callable(func): raise ValueError('Must pass callable functions') def inner(value): for func in fu

Re: How many times does unittest run each test?

2013-08-10 Thread Josh English
ebugging, because it is pretty straightforward and can be activated for a small section of the module. My modules run long (3,000 lines or so) and finding all those dastardly print statements is a pain, and littering my code with "if debug: print message" clauses. Logging just makes it simple. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: How many times does unittest run each test?

2013-08-10 Thread Josh English
. I'm working a feature that allows the checker to call a function to get acceptable values, instead of defining them at the start of the program. I included all of that because it's the shape of the script I'm working with. The real problem was setting additional handlers where they shouldn't be. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: How many times does unittest run each test?

2013-08-10 Thread Josh English
Aha. Thanks, Ned. This is the answer I was looking for. I use logging in the real classes, and thought that turning setting the level to logging.DEBUG once was easier than hunting down four score of print statements. Josh On Sat, Aug 10, 2013 at 3:52 PM, Ned Batchelder wrote: > On 8/10/13 4

Re: How many times does unittest run each test?

2013-08-10 Thread Josh English
On Saturday, August 10, 2013 1:40:43 PM UTC-7, Roy Smith wrote: > In article , > > Josh English wrote: > The first thing to do is get this down to some minimal amount of code > that demonstrates the problem. > > > > For example, you drag in the logging modul

How many times does unittest run each test?

2013-08-10 Thread Josh English
f SimpleChecker - DEBUG - calling f -- Ran 2 tests in 0.013s OK Exit code: False Why am I seeing those extra debugging lines? In the script I'm really trying to debug, I see 12-13 debug messages repeated, making actual debugging difficult. Josh English -- http://mail.python.org/mailman/listinfo/python-list

Re: why not?

2013-01-21 Thread Josh Benner
On Mon, Jan 21, 2013 at 7:56 AM, Lie Ryan wrote: > On 22/01/13 04:02, kwakukwat...@gmail.com wrote: > >> f = open(r'c:\text\somefile.txt') >> for i in range(3): >> print str(i) + ': ' + f.readline(), >> please with the print str(i) + ‘: ‘ + f.readline(), why not print str(i) >> + f.readli

Re: Help with Singleton SafeConfigParser

2012-12-08 Thread Josh English
e, and when I saw the tirades against Singletons they mentioned "use modules" but, well, I haven't had my morning coffee yet. I shouldn't even be trying this sort of thing until then. Thank you for the simple answer. Josh -- http://mail.python.org/mailman/listinfo/python-list

Help with Singleton SafeConfigParser

2012-12-08 Thread Josh English
('local.txt','w') as f: self.write(f) __options = Options() def set(section, name, value): return self.__options.set(section, name, value) def options(section): return self.__options.options # And so on This seems incredibly wasteful, and to introspect my options I get a module, not a SafeConfigParser object, so I'm wondering if there is a different way to handle this? Josh -- http://mail.python.org/mailman/listinfo/python-list

Splitting a line while keeping quoted items together

2012-11-19 Thread josh
;]: append = True appended = [item[1:]] quote = item[0] else: res.append(item) return res .. This seem really ugly. Is there a cleaner way to do this? Is there a keyword I could search by to find something nicer? Thanks, Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: format() not behaving as expected

2012-06-29 Thread Josh English
Personally, I find the documentation about format to be less than > helpful.) > Thanks. I think it's coming together. Either way, this format seems uglier than what I had before, and it's longer to type out. I suppose that's just programmers preference. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: format() not behaving as expected

2012-06-29 Thread Josh English
quot;.format(c) > foo > >>> format(c, "s") > 'foo' Thank you. That's beginning to make sense to me. If I understand this, everything between the braces is the format specification, and the format specification doesn't include the braces, right? Josh -- http://mail.python.org/mailman/listinfo/python-list

format() not behaving as expected

2012-06-29 Thread Josh English
I have a list of tuples, and usually print them using: print c, " ".join(map(str, list_of_tuples)) This is beginning to feel clunky (but gives me essentially what I want), and I thought there was a better, more concise, way to achieve this, so I explored the new string format and format() funct

Re: Getting lazy with decorators

2012-06-27 Thread Josh English
e in your __getattr__ override. Boy is my face red. On further experimentation, adding a do_xxx command without the decorator still works...ish. The undecorated do_xxx is still considered to have a help function, and it prints the raw docstring (instead of using the show_help method to clea

Re: Getting lazy with decorators

2012-06-25 Thread Josh English
On Sunday, June 24, 2012 1:07:45 AM UTC-7, Peter Otten wrote: > > You cannot access a class instance because even the class itself doesn't > exist yet. You could get hold of the class namespace with sys._getframe(), > > def add_help(f): > exec """\ > def help_%s(self): > f = getattr(self

Getting lazy with decorators

2012-06-23 Thread Josh English
I'm creating a cmd.Cmd class, and I have developed a helper method to easily handle help_xxx methods. I'm trying to figure out if there is an even lazier way I could do this with decorators. Here is the code: * import cmd def add_help(func): if not hasattr(func, 'im_cl

understanding operator overloading

2012-06-01 Thread Josh Benner
n(self.data) -> self.data = [1, 2, 4] __getitem__(index) -> index = slice(-1, 9223372036854775807, None) [4] printing blist[-2] __getitem__(index) -> index = -2 2 Best, Josh Benner -- http://mail.python.org/mailman/listinfo/python-list

Re: %d not working in re at Python 2.7?

2012-05-14 Thread Josh McGee
% On Friday, May 11, 2012 11:58:01 AM UTC-7, vacu wrote: > I am frustrated to see %d not working in my Python 2.7 re.search, like > this example: > > >>> (re.search('%d', "asdfdsf78asdfdf")).group(0) > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'NoneType' object

Re: PyTextile Question

2012-05-14 Thread Josh English
is works. I'm trying to figure what that regular expression does, but I swear it's copying the lines twice. (Clearly, I don't speak re.) Josh -- http://mail.python.org/mailman/listinfo/python-list

PyTextile Question

2012-05-03 Thread Josh English
y its own P-tag. Hopefully (again), I won't have a bunch of unwanted BR tags thrown in. I've tried several ways of pre-processing the text in the node, but pytextile still gives me line breaks. Any suggestions? Is there a good tutorial for PyTextile that I have

Re: xlrd 0.7.4 released!

2012-04-03 Thread Josh English
pdated. If I try to update again, it says it's already there. When I try to import xlrd, I get an error IOError: [Errno 2] No such file or directory: 'C:\\Users\\josh\\Desktop\\Portable Python\\App\\lib\\site-packages\\xlrd-0.7.5-py2.7.egg\\xlrd\\version.txt' I also noticed that in my

Re: Udacity CS 101

2012-03-02 Thread Josh English
On Monday, February 27, 2012 6:37:25 PM UTC-8, Ray Clark wrote: > > You have to remember that this course assumes no prior computer > programming knowledge. > > I agree, it is starting out very basic. Give it some more time. > These guys have PhDs from MIT and/or have taught at Stanford. They >

Udacity CS 101

2012-02-25 Thread Josh English
Has anyone here looked at Udacity's open CS101 course (http://www.udacity.com/overview/Course/cs101) that started this week? The goal of the seven week course is to build a web crawler. So far, I'm not impressed with the speed or content of the course. I was wondering what anyone here may think

Re: Deleting files on a shared server

2011-10-06 Thread Josh English
The problem shows up when the application starts. It tries to read the file but the lock mechanism times out because the file is still around after the last time the application ran. It's a wxPython program. The code to unlink the .lock files is run in the wxApp.OnInit method (before any code t

Deleting files on a shared server

2011-10-06 Thread Josh English
to the wxPython Application object) that hunts down .lock files and deletes them. Is there a better command than os.unlink to delete a file on Windows 2003 server? Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Understanding .pth in site-packages

2011-08-27 Thread Josh English
e-packages/foo before it finds and reads site-packages/foo.pth. At least this solution gives me a way to develop my libraries outside of site-packages. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Understanding .pth in site-packages

2011-08-27 Thread Josh English
When I run: os.listdir('c:\Python27\lib\site-packages') I get the contents in order, so the folders come before .pth files (as nothing comes before something.) I would guess Python is using os.listdir. Why wouldn't it? -- http://mail.python.org/mailman/listinfo/python-list

Re: Understanding .pth in site-packages

2011-08-27 Thread Josh English
eople from seeing the code? Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Understanding .pth in site-packages

2011-08-27 Thread Josh English
kages directory 2. an Egg file (still unsure why) 3. A .pth file It's a strange juju that I haven't figured out yet. Thanks for the hint. Josh -- http://mail.python.org/mailman/listinfo/python-list

Understanding .pth in site-packages

2011-08-27 Thread Josh English
PYTHONPATH variable? Josh -- http://mail.python.org/mailman/listinfo/python-list

Understanding .pth files

2011-08-27 Thread Josh English
folder) So my C:\Python27\lib\site-packages\xmldb.pth file has one line: c:\dev\XmlDB\xmldb (I've tried the slashes the other way, too, but it doesn't seem to work). Is the only solution to delete the installed library and add the dev folder to my site.py file? Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with regular expression in python

2011-08-18 Thread Josh Benner
On Thu, Aug 18, 2011 at 4:03 PM, Matt Funk wrote: > Hi guys, > > thanks for the suggestions. I had tried the white space before as well (to > no > avail). So here is the expression i am using (based on suggestions), but > still > no success: > > instance_linetype_pattern_str =\ >r'(([-+]?

import hooks (PEP 302) broken in Python >=2.5?

2011-08-07 Thread Josh Haberman
iding when writing new code. --http://orestis.gr/blog/2008/12/20/python-import-hooks/#c264 Does anyone know what this is referring to? Should I be wary of relying on import hooks? Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: removing nested iffs

2011-07-29 Thread Josh Benner
On Fri, Jul 29, 2011 at 1:07 PM, Wolfgang Rohdewald wrote: > On Freitag 29 Juli 2011, Josh Benner wrote: > > if args.build not None: > > which python version understands this? > > -- > Wolfgang > Apparently the version running in my head understands it ;-) Sorr

removing nested iffs

2011-07-29 Thread Josh Benner
I'm writing a function to create a string that gets longer iff an argument is defined. In there a more elegant way than nesting all those ifs? def format_rsync_src_string(args, server="RSYNC"): """ Format an rsync source directory string. """ if args.server is None: raise CopyNigh

Re: Looking for general advice on complex program

2011-07-18 Thread Josh English
That would be one of mine, probably. http://code.google.com/p/pyxmlcheck/ It's an old version. I haven't updated it in a while. And while my program worked fine at home, my test environment gave me some grief. Apparently the lock files are being deleted properly. I have a few ideas about that,

Re: Looking for general advice on complex program

2011-07-17 Thread Josh English
guy who almost has to re-invent the wheel. When I started XML processing, it was on an old computer and I couldn't get things like lxml to work, or understand the ones I did manage to install. To fully understand XML processing and validating, I had to write my own XML validation utility. J

Re: Looking for general advice on complex program

2011-07-16 Thread Josh English
uters on the network, and I don't know if I can make a socket work. I do know they put an internal wiki in the system, and if I could figure out how to do these requests over HTTP, I may try that, but that seems to be the wrong solution. (Yes, I am a programming neophyte way over my he

Re: Looking for general advice on complex program

2011-07-16 Thread Josh English
nd leaves the memory filled. If it does, I don't know if the OS will overwrite that memory. I'm afraid of taking up lots of space that I don't need with this program. The docs indicate that Unix recovers the memory, but I'm not sure about Windows. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for general advice on complex program

2011-07-16 Thread Josh English
Cameron, You use a directory as lock mechanism. I think I get how that works. When you're done manipulating the file, do you just remove the director? Josh -- http://mail.python.org/mailman/listinfo/python-list

Looking for general advice on complex program

2011-07-15 Thread Josh English
nk, to have a way to check if the GUI is editing a node before the XManager reads the file, so the thread needs to be interrupted, or paused, because I don't know if threads would stop if a wxDialog is being show modally or not. So, am I on the right track here? josh -- http://mail.py

Re: text file

2011-06-30 Thread Josh Benner
import os lst = [] for x in xrange(1, 5001): lst.append(r"Data\ma{0}.wav Data\ma{0}.mfc".format(x)) lst.insert(x-1, r"Data\ja{0}.wav Data\ja{0}.mfc".format(x)) with open("filename.txt", "w") as fd: sep = os.linesep fd.write(sep.join(lst)) On Thu, Jun 30, 2011 at 5:19 PM, Sibonis

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Josh Benner
On Fri, Feb 11, 2011 at 1:51 PM, Dan Stromberg wrote: > On Fri, Feb 11, 2011 at 1:43 PM, André Roberge > wrote: > > On Friday, February 11, 2011 5:24:15 PM UTC-4, LL.Snark wrote: > >> Hi, > >> > >> I'm looking for a pythonic way to translate this short Ruby code : > >> t=[6,7,8,6,7,9,8,4,3,6,7]

Re: frequency of values in a field

2011-02-09 Thread Josh English
is a list with the records you want, or an iterator that goes through the records. The get_key function does whatever you need it to do to get the key by which you are counting. Andreas offers a nice pythonic solution in this thread. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: frequency of values in a field

2011-02-09 Thread Josh English
mports whatsoever," the code would look like: counts = {} for thing in long_list: key = make_key(thing) if key in counts: counts[key] += 1 else: counts[key] = 1 But using a few imports is cleaner and just as easy to troubleshoot. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: frequency of values in a field

2011-02-08 Thread Josh English
sure what you want get_last_two_digits to look like from your post, or how you would get the long_list, which is just an iterator through your records. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Remove whitespaces and line breaks in a XML file

2011-02-07 Thread Josh English
I found the code posted at http://infix.se/2007/02/06/gentlemen-indent-your-xml quite helpful in turning my xml into human-readable structures. It works best for XML-Data. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Python use growing fast

2011-01-11 Thread Josh Benner
his article ... http://neopythonic.blogspot.com/2009/11/python-in-scientific-world.html ... the answer is python. Josh Benner -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem inserting an element where I want it using lxml

2011-01-04 Thread Josh English
Oh, and I usually use a separate function to indent my xml for readability when I need to actually look at the xml. It's easier than trying to change the element in situ and make it look nice. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem inserting an element where I want it using lxml

2011-01-04 Thread Josh English
, new_child) new_child.text=str(text) return new_child I don't think you need to count the instances of the bingo node (unless you want to prevent too many from being added in). Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Which coding style is better? public API or private method inside class definition

2011-01-04 Thread Josh English
r to change one thing once instead of one thing twice. In general, I try to code in a way that will reduce the number of places I'll have to change or refactor. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiple instances and wrong parental links

2011-01-02 Thread Josh English
always goes back to the original XML element (an elementree.Element object in this case.) Insanely complicated and just beyond my comprehension, I fear. I haven't found an easier way to wrap an object around these XML validators of mine. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiple instances and wrong parental links

2011-01-02 Thread Josh English
returns. (yeah, it's complicated). This is the same project I asked about at https://groups.google.com/d/topic/comp.lang.python/K9PinAbuCJk/discussion. That's why this simple sample looks so incredibly complicated. I'm coding on the far edge of my learning curve. Josh -- http://mail.python.org/mailman/listinfo/python-list

Multiple instances and wrong parental links

2011-01-01 Thread Josh English
p.__name__= checker.title() return Wrap if __name__ == '__main__': Dude = MakeWrapper('Dude') print Dude d1 = Dude('Josh') print d1, d1.stuff # creating the second instance changes the behavior of the subclass d2 = Dude('Ben'

Re: HTMLParser not parsing whole html file

2010-10-24 Thread josh logan
On Oct 24, 4:38 pm, josh logan wrote: > On Oct 24, 4:36 pm, josh logan wrote: > > > > > > > Hello, > > > I wanted to use python to scrub an html file for score data, but I'm > > having trouble. > > I'm using HTMLParser, and the parsing see

Re: HTMLParser not parsing whole html file

2010-10-24 Thread josh logan
On Oct 24, 4:36 pm, josh logan wrote: > Hello, > > I wanted to use python to scrub an html file for score data, but I'm > having trouble. > I'm using HTMLParser, and the parsing seems to fizzle out around line > 192 or so. None of the event functions are being calle

HTMLParser not parsing whole html file

2010-10-24 Thread josh logan
Hello, I wanted to use python to scrub an html file for score data, but I'm having trouble. I'm using HTMLParser, and the parsing seems to fizzle out around line 192 or so. None of the event functions are being called anymore (handle_starttag, handle_endtag, etc.) and I don't understand why, becau

Re: palindrome iteration

2010-08-29 Thread Josh English
I have no idea. That's a lower level of programming than I'm used to dealing with. Josh (I also only tried the one value. Had I tried with other strings that would fail the test, some functions may have performed better.) On Aug 29, 2:19 am, Matteo Landi wrote: > Well, I tried

Re: palindrome iteration

2010-08-28 Thread Josh English
rsed") print "is_palindrome_reversed", min(t.repeat()) The results: is_palindrome_recursive 6.32680866827 is_palindrome_slice 1.23618350114 is_palindrome_list 4.60104846653 is_palindrome_reversed 5.99355296513 The slice method is uglier, I have to admit, but it's the fastest of these four on my machine. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Tag parsing in python

2010-08-28 Thread Josh English
ds qualifying the other keywords so on.. > So I would like to know the python way of doing this. Is there any > library already existing for making my work easier. ? > > ~ > Agnibhu Have you looked at pyparsing? (http://pyparsing.wikispaces.com/) It may be possible to use that library to do this. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: pyxser-1.5r --- Python Object to XML serializer/deserializer

2010-08-28 Thread Josh English
On Aug 26, 10:02 pm, Stefan Behnel wrote: > Josh English, 27.08.2010 01:30: > > > solve a lot of the problems I'm running into in my own attempt to > > build a python Class implementation of an XML Validation object. > > How would object serialisation help here? &

Re: pyxser-1.5r --- Python Object to XML serializer/deserializer

2010-08-26 Thread Josh English
It looks nice, but it's a shame it doesn't work on Windows. This could solve a lot of the problems I'm running into in my own attempt to build a python Class implementation of an XML Validation object. -- http://mail.python.org/mailman/listinfo/python-list

Re: Namespace problem?

2010-07-02 Thread Josh English
he clue. I added one parameter to one function elsewhere and the thing seems to be working again. Thanks for the help. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: Namespace problem?

2010-07-01 Thread Josh English
On Jul 1, 2:50 pm, Matt McCredie wrote: > > That doesn't give me enough information to help you with the issue. In general > you need to provide enough code to reproduce the failure, not some modified > version that doesn't fail. My guess is that the "if True" is actually > something > else, and

Namespace problem?

2010-07-01 Thread Josh English
I have a script that generates a report from a bunch of data I've been collecting for the past year. I ran the script, successfully, for several weeks on test runs and creating more detailed reports. Today (back from vacation) and the script doesn't work. It's giving me a name error. I'm running

Re: Python Line Intersection

2010-04-09 Thread Josh English
On Apr 9, 8:36 am, Emile van Sebille wrote: > On 4/9/2010 8:04 AM Peyman Askari said... > > > Hello > > > This is partly Python related, although it might end up being more math > > related. > > > I am using PyGTK (GUI builder for Python) and I need to find the > > intersection point for two lin

Re: Dynamic Class Creation

2010-03-16 Thread Josh English
a bit of a bear. In short, I have to figure out the whole object interface to the XML and how I want that to work. Thanks for the suggestion. It is undeniably clever. Josh -- http://mail.python.org/mailman/listinfo/python-list

Re: datetime string conversion error

2010-03-16 Thread Josh English
teError: 'module' object has no attribute 'day_abbr' err... what? Is this an old weirdness I don't remember from the 2.5 series? I can select dates in the calendar, but nothing dismisses it but the close box. Josh English Incredibly Confused -- http://mail.python.org/mailman/listinfo/python-list

  1   2   3   >