r p in patterns:
> if fnmatch.fnmatch(some_file_name, p):
> return True
I don't see anything in the fnmatch and glob modules... but I didn't look
very hard because what the heck is wrong with the four line solution you
have? Looks fine to me.
--
Brian Beck
Adventurer of the
Martin P. Hellwig wrote:
> Speaking of that, is there any reason why there isn't any syntactic
> sugar that gives the illusion of platform neutral fetching of the user
> name?
getpass.getuser() might come the closest:
http://docs.python.org/lib/module-getpass.html
--
Brian Beck
ument to reduce(), using operator.attrgetter just makes the
definition more complicated (see my other post).
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
return obj
I'll raise you one:
def cattrgetter(attr):
return lambda obj: reduce(getattr, attr.split('.'), obj)
py> class A: pass
py> a = A
py> a.b = A
py> a.b.c = "Hey!"
py> cattrgetter('b.c')(a)
'Hey!'
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
et.union, sets) - reduce(set.intersection, sets)
set([1, 2])
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
502: 38.89875, -77.03768
py> from geopy import distance
py> _, a = us.geocode('10900 Euclid Ave, Cleveland, OH 44106')
py> _, b = us.geocode('1600 Pennsylvania Ave, Washington, DC')
py> distance.distance(a, b).miles
301.35526872700962
py> from geopy import util
py>
he rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies provided
they keep the license text with the library.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
Brian Beck wrote:
> What is dmath?
> ==
> dmath provides the standard math routines for Python's arbitrary-precision
> Decimal type. These include acos, asin, atan, atan2, ceil, cos, cosh,
> degrees, e, exp, floor, golden_ratio, hypot, log, log10, pi, pow, radian
imal as D, getcontext
>>> getcontext().prec = 50
>>> asin(D(1))
Decimal("1.5707963267948966192313216916397514420985846996876")
>>> golden_ratio()
Decimal("1.6180339887498948482045868343656381177203091798058")
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
Brian Beck wrote:
> I'm happy to announce the first (alpha) release of geopy, a geocoding
> toolbox for Python: http://exogen.case.edu/projects/geopy/
For anyone interested, there is now a mailing list on Google Groups:
http://groups.google.com/group/geopy
geopy also now supports
$ svn co svn://exogen.case.edu/geopy/trunk geopy-trunk
$ cd geopy-trunk/
$ sudo python setup.py install
...or use easy_install:
$ sudo easy_install svn://exogen.case.edu/geopy/trunk
Questions, comments, and bug reports can be directed to: [EMAIL PROTECTED]
--
Brian Beck
Adventurer of the First Or
e for how to use it:
http://www.amk.ca/python/howto/unicode
I'm not sure if it has built-in support for finding which language block a
character is in, but a table like this might help you:
http://www.unicode.org/Public/UNIDATA/Blocks.txt
--
Brian Beck
Adventurer of the First Order
--
htt
[EMAIL PROTECTED] wrote:
> The trick is finding the right . Has someone attempted this
> before, or am I stuck writing my own solution?
You want ASCII, Dammit: http://www.crummy.com/cgi-bin/msm/map.cgi/ASCII
+Dammit
--
Brian Beck
Adventurer of the First Order
--
http://mail.pyth
Yves Lange wrote:
> Other solutions:
> you can try the rar command line from WinRar but it's not recommended.
> This is a very slow manner to compress file.
Are you sure? This worked about 4 times faster than the zip command line
utility in Linux, compressing the same files...
archive, but I'm assuming it just involves writing an
arcname with a '/' in it (see help(zipfile.ZipFile)).
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
Is that possible?)
No, for the reason above -- there is no magic method associated with ++,
which isn't a real Python operator.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
start: http://pythoncard.sourceforge.net/
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
For certain errors like Syntax Errors, you'll get a much more helpful
response if you post some actual code. Strip it down if you have to,
but make sure we can reproduce the errors.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> http://www.doxdesk.com/img/software/py/icons.png
Great work! Add an icon for Python egg files and you've covered all the
bases.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
nterface to our classes
to support models that rely on caching, etc.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
John Zenger wrote:
> Also, get rid of the comma at the end of that last print statement.
This would break the progress bar functionality I think, which is meant
to update a single line.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
> I don't think either of these would help in this case. While the
> length of the compressed string might be significantly shorter than
> your solution, the resulting string *literal* you decompress will
> contain a bunch of \-escaped characters, so it will end up being longer.
PS: I'm at 155, d
anonymous wrote:
> are you importing zlib or bz2 ?
I don't think either of these would help in this case. While the
length of the compressed string might be significantly shorter than
your solution, the resulting string *literal* you decompress will
contain a bunch of \-escaped characters, so it
ymorphic
> if ():
>obj = D1()
> else:
>obj = D2()
I have no idea what you're trying to do here and how it relates to
polymorphism.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
the above...
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/415500
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
here is such a huge counter-example of "the best
technology wins" staring everyone in the face every day, that the first
part of your post doesn't really do anything for me.
But ultimately I am on your side. Python has a long way to go, and it
has nothing to do with the language
David Blomstrom wrote:
> This is my first post on this list, and I'm new to
> Python.
Oh, and I forgot to mention: welcome to Python and our community!
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
get Zope up
and running before you can use Plone. See www.zope.org. There are also
specific mailing lists (on Gmane, www.gmane.org) dedicated to Zope,
Plone, and their related packages.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
siblings of X and B (subpaths of B and A).
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
#x27;s __mro__ solution returns the bases in reverse
order than what you requested (in your example, you said B should come
last). So use list(reversed(z.__class__.__mro__)) or
z.__class__.__mro__[::-1]
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
Ivan Van Laningham wrote:
> I like / as a shortcut to joinwith(). I like it a lot. I like it so
> much I'll give you a +2.
+1 here. Extremely practical.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
ar"
py> s[:3]
'foo'
py> s[:3] + "B" + s[4:]
'fooBar'
py>
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
> I think this seems to be a problem due to the use of a forbidden word. But I
> have no chance to change the WSDL definition, so: How can I get the
> variable resp.return? Any suggestions?
To get it: getattr(resp, 'return')
To set it: setattr(resp, 'return', value)
Elliot Temple wrote:
> How do I make Python press a button on a webpage? I looked at
> urllib, but I only see how to open a URL with that. I searched
> google but no luck.
Check out mechanize: http://wwwsearch.sourceforge.net/mechanize/
--
Brian Beck
Adventurer of the First Order
Well, there are two distinct features of IntelliSense as you know it.
One is auto-completion and the other is contextual help.
Auto-completion is included almost all beefy Python IDE's.
Contextual help is included even in IDLE, where if you begin typing a
function call, its docstring pops up arou
:
d = {}
for filename in files:
d[sha_func(filename)] = filename
Or like so:
d = dict([(sha_func(filename), filename) for filename in files])
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
ect way to do
>> so? Or must I
>>
>> list = []
>>
>> for item in set1:
>>list.append(item)
>>
>> list.sort()
So, for this example, just do:
sorted(set1)
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
ple: date.today().strftime("%B %d, %Y")
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
izing that it's in the local scope now. So it's fine all the modules
fine, just placing them wrong in the auto-complete search tree, or
however it works.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
or other modules in the standard
library. But calls to standard library modules only occur maybe twice in
any of my big scripts... the problem is I've been trying code completion
with third-party modules and local classes, which still doesn't work.
--
Brian Beck
Adventurer of the Firs
Brian Beck wrote:
> I realize 0.9.3 is the latest release, but the installation fails
> through the Eclipse updater:
>
> Unable to complete action for feature "PyDev for Eclipse" due to errors.
> Unable to create file
> "/opt/eclipse-extensions-3/eclipse/plu
Brian Beck wrote:
>>What version? PyDev has increased in maturity quite a bit lately.
I realize 0.9.3 is the latest release, but the installation fails
through the Eclipse updater:
Unable to complete action for feature "PyDev for Eclipse" due to errors.
Unable to create fi
Oh yeah, and what's with not being able to configure the code completion
key sequence. How about *no* key sequence? That's the way every other
IDE I've used does it. This is more like semi-automatic code completion.
--
Brian Beck
Adventurer of the First Order
--
http://mail.pyt
ter, such as dedenting after a 'return'
statement.
* The Problems view finds 52 errors in a file with 0.
* Run As doesn't dump me into an interactive shell.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
pable. The autocompletion is
very generic though, it'll happily complete any word you've typed
before. The auto-indentation isn't nearly as spot-on as WingIDE's
* I hate PythonWin or whatever it's called. Dunno what more to say
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
ith an attrgetter, but apparently my
understanding of that isn't perfect... it groups by the identify of the
bound method instead of calling it...
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
something resembling:
LoadModule python_module modules/mod_python.so
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
should result in
the number unchanged. As his tests show, this is not the case. This is
because the operation works only if the least significant bit actually
NEEDS to be unset. To zero the least significant bit unconditionally, we
can use:
x &= ~1
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
Maybe this can help you get it working on OS X:
http://thread.gmane.org/gmane.comp.python.mod-python/4039
But as stated in my other post, you may want to take a look at your
other options first. Web development with Python is really nothing like
PHP, unless you really want it to be.
--
Brian
ant; and that's not
necessarily a good thing. Vampire points you in a nice direction (I
don't want to say 'the right' direction).
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
) for s in sets if s]
# Comparison
import profile
import random
# Play with these values
xMax, nPairs = 1000, 5000
l = [[random.randint(0, xMax), random.randint(0, xMax)] for i in
range(nPairs)]
print 'merge2:'
profile.run('merge2(l)') # Mine
print 'merge:'
profile.ru
removePairs.add(pair) # Mark pair for removal
if removePairs:
pairList -= removePairs
else:
merged.append(list(subList))
return merged
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
Brian Beck wrote:
Brian Beck wrote:
> [code]
Ah heck, nevermind... it worked for my small test cases but the
algorithm is just wrong.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
Brian Beck wrote:
> [code]
Whoops, that should say:
def merge(pairs):
pairs = set(tuple(sorted(p)) for p in pairs)
merged = []
# Each loop will result in a new, complete sublist in the result.
while pairs:
p = set(pairs.pop())
remove = set([])
for pair
pairs:
p = set(pairings.pop())
remove = set([])
for pair in pairs:
pairSet = set(pair)
if pairSet & p:
p |= pairSet
remove.add(pair)
pairs -= remove
merged.append(list(p))
return merged
--
Brian
um problem.'
http://en.wikipedia.org/wiki/Subset_sum_problem
http://en.wikipedia.org/wiki/Knapsack_problem
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
x27;word' totalled over all selected dicts doesn't exceed a given
MAX_VALUE. Right now, I do this by:
Not that you can't still improve performance of course, but this is an
NP-complete problem if you didn't know, so don't bang your head too hard...
--
Brian
Martin Christensen wrote:
A math teacher! A math teacher! My kingdom for a math teacher!
Martin
Man, this is the hottest topic on c.l.py since that Lazaridis guy...
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
he does have to *multiply* by a
thousand to get the number of milliseconds.
2 seconds * 1000 = 2000 milliseconds
So, aside from the 100 in the original post, it may look misleading, but
that is what he would need to do...
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/
Fredrik Lundh wrote:
Brian Beck wrote:
That IS what you want.
seconds * 100 = milliseconds
are you sure you know what a millisecond is?
(duck)
Touché.
But it was a typo.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
mjs7231 wrote:
This is no good, I am looking for milliseconds, not seconds.. as stated
above.
That IS what you want.
seconds * 100 = milliseconds
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
t wizardly enough to comment on.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
development work to enhance the standard Python
distribution IS volunteering.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
nd don't require the setup of a try/except/else.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
onsidering I have to do stuff like this on a daily basis!
Ignore mine except as a novelty, then.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
r x in ['a', '', 'b', 'c']))
False
py> bool(min(bool(x) for x in ['a', 'b', 'c', 'd']))
True
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
Brian Beck wrote:
def all(seq, pred=bool):
"Returns True if pred(x) is True for every element in the iterable"
for elem in ifilterfalse(pred, seq):
return False
return True
def any(seq, pred=bool):
"Returns True if pred(x) is True for at least one element i
(x) is True for every element in the iterable"
for elem in ifilterfalse(pred, seq):
return False
return True
def any(seq, pred=bool):
"Returns True if pred(x) is True for at least one element in the
iterable"
for elem in ifilter(pred, seq):
return True
son actually using it. So string substitution makes it more
flexible; less work for them.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
ot;File not found: %s" % fileName
# To close optionalFiles...
for fileName, fileObject in optionalFiles.iteritems():
if fileObject:
fileObject.close()
print "Closed: %s" % fileName
# Rebinding fileObject here won't modify the dictionary,
ntation: loss of data integrity and
possibly even data itself, or speed and efficiency?
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
h
complex APIs that Python will rarely help you.
Of course there are more, like Webware, but you didn't mention that and
I don't have experience with it.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
Anyone have any suggestions? The only other thing I looked at was
twisted, which I'm still evaluating.
Might as well check out CherryPy as well. www.cherrypy.org
Might turn out to be simpler for your needs.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/lis
ine
where I would start if I were them. Once I get to the BeginnersGuide I
don't see anything immediately useful, and when I look for it I get
frustrated.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
e forms, both geared
towards being input to an search method for your database
I'd be glad to post the code, although I'd probably want to have a last
look at it before I let others see it...
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
t;
and {}'s are clearly already used for dictionaries.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
It's me wrote:
How do I know if arg1 is a single type (like a number), or a list?
isinstance is probably good enough for your needs.
if isinstance(arg1, (list, tuple, dict)):
print "arg1 is a container"
else:
print "arg1 is (probably) not a container"
--
Brian Bec
bers, same ranking.
Good analogy.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
;s a syntax to tell the Python interpreter which
characters in your string are 'special' and has no effect on strings not
input as literals directly within your code. Strings from files or any
input besides the interactive Python shell will already be what you're
looking for.
cwru.edu/python2.png
If anyone can think of a way to break free of the reptile-oriented
thought process but maintain clear, symbolic imagery, I'd love to see
more suggestions or renditions!
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
o remember seeing that message but thought "no way" since the Windows
firewall is pretty forgiving in my experience. But after a bit of
tweaking and even disabling the firewall completely, the problem persists.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mai
Brian Beck wrote:
I have the exact same problem. The IDLE window just never opens, and
checking the process list shows that is was never even launched. So I
can't make much use of Python 2.4 since I use IDLE as my IDE...
I forgot to note that I am also using Windows XP SP2 and this happe
ve it? Thanks!
I have the exact same problem. The IDLE window just never opens, and
checking the process list shows that is was never even launched. So I
can't make much use of Python 2.4 since I use IDLE as my IDE...
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.o
to change precedence or to clear search term
ambiguity. These are likewise completely ignored.
;)
Have a helpful day.
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list
84 matches
Mail list logo