Re: Detecting Binary content in files

2009-03-31 Thread Josh Dukes
', '/etc/passwd']: print "%s is binary: " %f, isbin(f) whatever... basically it's what everyone else said, every file is binary so it all depends on your definitiion of binary. On Tue, 31 Mar 2009 10:23:51 -0700 Josh Dukes wrote: > s/if ord(b) > 127/if ord(b

Re: Detecting Binary content in files

2009-03-31 Thread Josh Dukes
s/if ord(b) > 127/if ord(b) > 127 or ord(b) < 32/ On Tue, 31 Mar 2009 10:19:44 -0700 Josh Dukes wrote: > There might be another way but off the top of my head: > > #!/usr/bin/env python > > def isbin(filename): >fd=open(filename,'rb') >for

Re: Detecting Binary content in files

2009-03-31 Thread Josh Dukes
thon > script that will tell me whether the file is binary), so any pointers > will be appreciated. > > Thanks, > Ritu > -- > http://mail.python.org/mailman/listinfo/python-list -- Josh Dukes MicroVu IT Department -- http://mail.python.org/mailman/listinfo/python-list

Re: Find duplicates in a list and count them ...

2009-03-26 Thread Josh Dukes
8): > > > l.append(randint(0,10)) > > ^^^ > > should have been: > > l.append(randint(0,9)) > > Or even: > > l = [randint(0,9) for x in xrange(8)] > -- Josh Dukes MicroVu IT Department -- http://mail.python.org/mailman/listinfo/python-list

Re: What way is the best to check an empty list?

2009-03-25 Thread Josh Dukes
Go to > http://messenger.yahoo.com/invite/ -- > http://mail.python.org/mailman/listinfo/python-list -- Josh Dukes MicroVu IT Department -- http://mail.python.org/mailman/listinfo/python-list

Re: iteration without storing a variable

2009-03-25 Thread Josh Dukes
I was more talking about the speed differences between ruby and python. On Wed, 25 Mar 2009 20:13:13 +0100 Stefan Behnel wrote: > Josh Dukes wrote: > > $ time python -c 'a = "A"; > > for r in xrange(10): a += "A" ' > > > > real0m0.

iteration without storing a variable

2009-03-25 Thread Josh Dukes
s essentially zero cost (sound right?). $ time python -c 'for r in xrange(100): pass' real0m0.210s user0m0.210s sys 0m0.000s $ time ruby -e '100.times { }' real0m0.259s user0m0.250s sys 0m0.000s Anyone see anything I missed? Any additional info? Anyone get different results? -- Josh Dukes MicroVu IT Department -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3D CAD -- need collaborators, or just brave souls :)

2009-03-18 Thread Josh Dukes
> VNC style remote control of other seats of the same software so parts > can be discussed with ease over the phone etc. It seems like project verse would be really cool to have for this. http://verse.blender.org/ -- Josh Dukes MicroVu IT Department -- http://mail.python.org/mailman/li

Re: Python 3D CAD -- need collaborators, or just brave souls :)

2009-03-17 Thread Josh Dukes
ux & osx.) > > We're starting to work on a high level API, so this is a wonderful > moment to jump on. > > > -jelle > > -- > http://mail.python.org/mailman/listinfo/python-list -- Josh Dukes MicroVu IT Department -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3D CAD -- need collaborators, or just brave souls :)

2009-02-18 Thread Josh Dukes
f > software from the middle ages. And i am absolutly only looking to do > this in 3D, 2D is boring. > > So, yes, i have looked at both the applications you offer. > > Thanks > -- > http://mail.python.org/mailman/listinfo/python-list -- Josh Dukes MicroVu IT Department -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3D CAD -- need collaborators, or just brave souls :)

2009-02-17 Thread Josh Dukes
ve. > > In any case, your project sounds interesting, and I'll > be happy to discuss ideas if you want. > -- Josh Dukes MicroVu IT Department -- http://mail.python.org/mailman/listinfo/python-list

Re: Putting asterisks around text

2009-02-17 Thread Josh Dukes
ate variables as True or False without a verbose test. e.g.: while not understand_problem: study("textbook") complete("homework") if want_help: study("http://www.catb.org/~esr/faqs/smart-questions.html";) Just fyi... -- Josh Dukes MicroVu IT Department -- http://mail.python.org/mailman/listinfo/python-list

Re: Scanning a file character by character

2009-02-17 Thread Josh Dukes
7;fox', 'jumps,', 'and', 'falls', > 'over.'] > > Note the difference in "jumps" vs. "jumps," (extra comma in the > string.split() version) and likewise the period after "over". > Thus not quite "the exact same thing as line.split()". > > I think an easier-to-read variant would be > >>>> re.findall(r"\w+", s) >['The', 'quick', 'brown', 'fox', 'jumps', 'and', 'falls', 'over'] > > which just finds words. One could also just limit it to letters with > >re.findall("[a-zA-Z]", s) > > as "\w" is a little more encompassing (letters and underscores) > if that's a problem. > > -tkc > > > > > -- > http://mail.python.org/mailman/listinfo/python-list -- Josh Dukes MicroVu IT Department -- http://mail.python.org/mailman/listinfo/python-list

Re: bool evaluations of generators vs lists

2009-02-10 Thread Josh Dukes
ahhh any! ok, yeah, I guess that's what I was looking for. Thanks. On 10 Feb 2009 21:57:56 GMT Steven D'Aprano wrote: > On Tue, 10 Feb 2009 12:50:02 -0800, Josh Dukes wrote: > > > The thing I don't understand is why a generator that has no iterable > > value

Re: bool evaluations of generators vs lists

2009-02-10 Thread Josh Dukes
ation that someone else might also want to do the same thing in real-world code. Is there another list I should be asking these questions on? -- Josh Dukes MicroVu IT Department#!/usr/bin/env python from datetime import datetime def has_values(g): for i in g: return True return

bool evaluations of generators vs lists

2009-02-10 Thread Josh Dukes
first value is detected*. I'd really expect it to act more like... def has_values(g): for i in g: return True return False So what's going on here? Am I using the wrong function or is this actually just a bug? -- Josh Dukes MicroVu IT Department -- http://mail.