On Mon, Jan 7, 2013 at 12:37 PM, Chris Angelico wrote:
> On Tue, Jan 8, 2013 at 10:35 AM, wrote:
>> download wxpython but whenever I try to use it I get this I’m a beginner in
>> python pls I need help.
>>
>> ImportError: DLL load failed: %1 is not a valid Win32 application.
>
> Did you download
On Tue, Jan 8, 2013 at 12:16 PM, Neal Becker wrote:
> Did you intend to give anyone permission to use the code? I see only a
> copyright notice, but no permissions.
It also says "Licence: python, Copyright notice may not be altered."
Which suggests to me that the intent is that it be licensed u
On Tue, Jan 8, 2013 at 2:22 PM, Roy Smith wrote:
> How do you tell how many weeks apart two datetimes (t1 and t2) are?
> The "obvious" solution would be:
>
> weeks = (t2 - t1) / timedelta(days=7)
>
> but that doesn't appear to be allowed. Is there some fundamental
> reason why timedelta division
On Tue, Jan 8, 2013 at 2:33 PM, Ian Kelly wrote:
> On Tue, Jan 8, 2013 at 2:22 PM, Roy Smith wrote:
>> How do you tell how many weeks apart two datetimes (t1 and t2) are?
>> The "obvious" solution would be:
>>
>> weeks = (t2 - t1) / timedelta(days=7)
>&g
On Thu, Jan 10, 2013 at 1:31 PM, pmec wrote:
> Hi Oscar, again I do apologize for my beginner mistakes, I've changed the
> code taking in consideration some of your and MRAB suggestions.
>
> Could you give me an example on how could I use the datetime.timedelta
> function in this particular case
On Fri, Jan 11, 2013 at 12:03 PM, Rotwang wrote:
> Hi all,
>
> the other day I 2to3'ed some code and found it ran much slower in 3.3.0 than
> 2.7.2. I fixed the problem but in the process of trying to diagnose it I've
> stumbled upon something weird that I hope someone here can explain to me. In
>
n. I also like to use
virtualenvwrapper for convenience, but it isn't necessary.
Ian F
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Jan 11, 2013 at 9:34 PM, Rick Johnson
wrote:
> No the rules are:
> * "Colon" must be used to access a "module" (or a package).
> * "Dot" must be used to access a "module member".
What about module a that does not natively contain module b, but
imports it as a member like so?
a.py
On Fri, Jan 11, 2013 at 10:28 PM, Rick Johnson
wrote:
> On Friday, January 11, 2013 12:30:27 AM UTC-6, Chris Angelico wrote:
>> Why is it better to import from the current directory first?
>
> Opps. I was not explicit enough with my explanation :). I meant, "look in the
> current directory FIRST
On Sat, Jan 12, 2013 at 1:38 AM, wrote:
> The difference between a correct (coherent) unicode handling and ...
This thread was about byte string concatenation, not unicode, so your
rant is not even on-topic here.
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, Jan 13, 2013 at 10:22 PM, Rick Johnson
wrote:
> You are missing the point of this syntax. The colon is to access MODULE
> NAMESPACE. The dot is to access MODULE MEMBERS. A module CAN BE another
> module's MEMBER.
>
> You are also unable to grasp this simple logical fact: Once you arrive
On Mon, Jan 14, 2013 at 11:51 AM, Ian Kelly wrote:
>> Because modules and objects are not the same and someone who is reading the
>> source code NEEDS to know which "path members" are /modules/ and which "path
>> members" are /objects/. And he needs to kn
On Mon, Jan 14, 2013 at 12:35 PM, D'Arcy J.M. Cain wrote:
> On Mon, 14 Jan 2013 11:51:50 -0700
> Ian Kelly wrote:
>> On Sun, Jan 13, 2013 at 10:22 PM, Rick Johnson
>> wrote:
> ...Whatever
>
>> If you want us to understand the syntax, then you need to defi
On Mon, Jan 14, 2013 at 9:51 PM, Rodrick Brown wrote:
> import sys
>
> PY3K = sys.version_info >= (3,)
>
>
> methods = set([
> "__iter__",
> "__len__",
> "__contains__",
>
> "__lt__",
> "__le__",
> "__eq__",
> "__ne__",
> "__gt__",
> "__ge__",
>
> "__add__",
On Tue, Jan 15, 2013 at 4:24 PM, J wrote:
> The exit code determination above works, but it just feels inelegant.
> It feels like there's a better way of implementing that, but I can't
> come up with one that still honors the fail level properly (e.g. other
> solutions will fail on medium, but won
r reason you disable right-click with javascript?
Regards,
Ian F
--
http://mail.python.org/mailman/listinfo/python-list
7;s my output:
>>> name = input("What is your name? ")
What is your name? Ian
>>> print("Hello" + name + "!")
HelloIan!
Your final print should be:
print("Hello " + name + "!")
Regards,
Ian F
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Jan 25, 2013 at 10:40 AM, lars van gemerden
wrote:
> Hi all,
>
> i was writing a function to determine the common base class of a number
> classes:
>
[...]
>
> and ran common_base(int, float), hoping to get numbers.Number.
>
> this did not work because abstract base classes are not always
On Fri, Jan 25, 2013 at 4:14 PM, Arnaud Delobelle wrote:
> Dear Pythoneers,
>
> I've got a seemingly simple problem, but for which I cannot find a
> simple solution.
>
> I have a set of objects (say S) containing an object which is equal to
> a given object (say x). So
>
> x in S
>
> is true.
On Fri, Jan 25, 2013 at 4:30 PM, Ian Kelly wrote:
> On Fri, Jan 25, 2013 at 4:14 PM, Arnaud Delobelle wrote:
>> Dear Pythoneers,
>>
>> I've got a seemingly simple problem, but for which I cannot find a
>> simple solution.
>>
>> I have a set of objects
On Fri, Jan 25, 2013 at 4:45 PM, MRAB wrote:
> You could first limit the search to only those which it could be:
>
> S & set([y])
>
> A search would be:
>
f = [m for m in S & set([y]) if m is y][0]
f is y
> True
But in practice he won't have y, only x. So that would have to be:
>>
On Wed, Jan 30, 2013 at 1:09 PM, Vinay Sajip wrote:
> Python 3.3 includes a script, pyvenv, which is used to create virtual
> environments. However, Distribute and pip are not installed in such
> environments - because, though they are popular, they are third-party
> packages - not part of Pyth
On Wed, Jan 30, 2013 at 2:16 PM, wrote:
> Hi everyone! I don't mean to intrude, but ive heard great things about this
> group and ive stumped myself with my python code.
>
> heres my code:
It would be helpful if you would also include the error that you get
when trying to run the code.
> globa
ns to be made, including rewriting parts of the program in
C.
"We should forget about small efficiencies, say about 97% of the time:
premature optimization is the root of all evil"
-- Donald Knuth
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
ute; in the second case, an instance attribute.
Either way, it would then be accessed simply as "self.foo".
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
> will create a 'MyApp' instance and then bind it to the name 'foo'.
> Until that binding occurs, the name 'foo' doesn't exist.
What MRAB said; also note that there is no need to bind your wx.App
instance to a name at all, because you can retrieve it globall
call has returned, so the result of that call has not
actually been assigned to "app" yet.
I suggest using wx.GetApp() instead.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Jan 23, 2012 at 2:52 PM, Jonno wrote:
> On Mon, Jan 23, 2012 at 3:42 PM, Ian Kelly wrote:
>>
>> Exactly. The line "app = MyApp(0)" creates a MyApp instance and then
>> assigns it to "app". As part of the MyApp creation process, it
>>
he latter and remove the reliance on
finding the correct frame?
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Jan 23, 2012 at 10:57 PM, Rick Johnson
wrote:
>
> Here is a grep
A grep? What is a grep? That word is not in any of my dictionaries.
Are you perhaps carelessly invoking the neologism of referring to an
execution of the "grep" UNIX program as "a grep"?
> from the month of September 2011
t; {NG.name} # Named Group Reference
> {#...} # Comment
> {>+...} # Positive Look Ahead Assertion
> {>-...} # Negative Look Ahead Assertion
> {<+...} # Positive Look Behind Assertion
> {<-...} # Positive Look Behind Assertion
> {(id/name)yes-pat|no-pat}
>
ther
meaning in other contexts is flatly ridiculous. The editors at
dictionary.com disagree with you too:
"""
Usage Note
The qualifying adverb pretty, meaning “fairly or moderately” has been
in general use since the late 16th century. Although most common in
informal speech and writi
re inherently unpythonic. While your
reimplementation may be more intuitive to you, I don't think that it's
more pythonic at all.
> Window dressing is important Ian, if not, then shop owners would not
> continue to show displays in their shop windows. What does window
>
On Wed, Jan 25, 2012 at 4:23 PM, Rick Johnson
wrote:
> Only to you. In my world, the "pleasurable aspects of a tangible
> object" can have no effect on my opinion of the difficulty of a task.
Then your world is not the real world, that being the one that is
actually described by every dictionary
On Wed, Jan 25, 2012 at 6:00 PM, Rick Johnson
wrote:
> On Jan 25, 6:20 pm, Ian Kelly wrote:
>> On Wed, Jan 25, 2012 at 4:23 PM, Rick Johnson
>
>> > """I was frightened that the finals might be difficult this year,
>> > however to my surprise, they
wo posts), that means that he is not just a
troll, but a successful troll.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Jan 31, 2012 at 2:07 PM, Prasad, Ramit
wrote:
>>Like Neil mentioned, a contextmanager generator is wrapped with an
>>__exit__ method that is guaranteed to be called and that explicitly
>>resumes or closes the generator. So as long as your contextmanager
>>generator is properly written (i.
docs are written the way that they are, but if
you check the code, you can see that PyTuple_SetItem will raise a
SystemError if the reference count is anything other than 1. So I
think that it is only meant to be used with similar caution and
restraint.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Jan 31, 2012 at 6:09 PM, Ian Kelly wrote:
> On Tue, Jan 31, 2012 at 5:53 PM, Chris Angelico wrote:
>> On Wed, Feb 1, 2012 at 9:03 AM, Duncan Booth
>> wrote:
>>> Abitrarily nested tuples of exceptions cannot contain loops so the code
>>> simply needs to
r assignment, use __setitem__.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
; f('pass')
Traceback (most recent call last):
File "", line 1, in
File "", line 3, in f
NameError: global name 'a' is not defined
>>> def f(x):
... locals()['a'] = 4
... print a
... exec x
...
>>> f('pass')
directly
reference it as 'a', though, since the result would be either that it
would try to look up a global with that name, or the compiler would
consider it a local, optimize it, and then you could no longer assign
it via locals().
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Feb 1, 2012 at 3:53 PM, Ethan Furman wrote:
> --> def f(x, y):
>
> ... locals()[x] = y
> ... print(vars())
> ... exec('print (' + x + ')')
> ... print(x)
> ...
> --> f('a', 42)
>
> {'y': 42, 'x': 'a', 'a': 42}
> 42
> a
>
> Indeed -- the point to keep in mind is that locals(
On Wed, Feb 1, 2012 at 4:41 PM, Ethan Furman wrote:
> I'm not sure what you mean by temporary:
>
> --> def f(x, y):
>
> ... frob = None
> ... loc = locals()
> ... loc[x] = y
> ... print(loc)
> ... print(locals())
> ... print(loc)
> ... print(locals())
> ...
> -->
> -->
n.
> Then how are you going to maintain the code? Maintain the compiled
> code or the source?
As with all compiled software, you maintain the input, not the output.
> And proving that your translator is always correct
That's what unit tests are for.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
> Yes, I do know that, but then it would not be a closure :-)
Sure it is. Where do you think it looks up the function object?
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
rate through pairs instead of individual
elements? It sounds like it is not very flexible. I would recommend
instead using the "grouper" recipe from the itertools documentation:
http://docs.python.org/library/itertools.html#recipes
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
def __iter__(self):
return iter(self.__dict)
def __getitem__(self, key):
return self.__dict[key]
def __hash__(self):
return hash(frozenset(self.__dict.iteritems()))
def __repr__(self):
return 'frozendict(%r)' % (self.__dict,)
Not extensiv
On Thu, Feb 9, 2012 at 8:19 AM, Nathan Rice
wrote:
> As I said, two dictionaries created from the same input will be the
> same...
That's an implementation detail, not a guarantee. It will hold for
current versions of CPython but not necessarily for other Python
implementations.
--
http://mail.
On Thu, Feb 9, 2012 at 11:53 AM, HoneyMonster wrote:
> One issue I have run into, which may or may not be a problem: I am
> finding that modules in the in-house "library" package sometimes have to
> import modules like sys and os, which are also imported by the "calling"
> module. Is this a proble
On Thu, Feb 9, 2012 at 5:30 PM, noydb wrote:
> How do you round down ALWAYS to nearest 100? Like, if I have number
> 3268, I want that rounded down to 3200. I'm doing my rounding like
round(3268, -2)
> But, how to round DOWN?
>>> 3268 // 100 * 100
3200
For more complicated cases, Decimal
On Thu, Feb 9, 2012 at 6:43 PM, Chris Rebert wrote:
> On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote:
>> hmmm, okay.
>>
>> So how would you round UP always? Say the number is 3219, so you want
>> 3300 returned.
>
> http://stackoverflow.com/questions/17944/how-to-round-up-the-result-of-integer-divis
are of though is that while the "round down" formula
works interchangeably for ints and floats, the "round up" formula does
not.
>>> (3300.5 + 99) // 100 * 100
3300.0
A more consistent alternative is to negate the number, round down, and
then negate again.
>>> -(-(3300.5) // 100 * 100)
3400.0
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
move(i)
...
0
2
4
6
8
>>> x
[1, 3, 5, 7, 9]
Had you attempted to remove any of the odd numbers as well, it would
have failed.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
o arguments, this results in the error you see.
There are a couple of ways you could fix this. The first would be to
change the signature of the __init__ method to take an optional
argument accepting the default factory instead of hard-coding it, like
this:
def __init__(self, default_factory=int):
On Sat, Feb 11, 2012 at 10:46 AM, Ian Kelly wrote:
> The problem is that defaultdict defines a custom __reduce__ method
> which is used by the pickle protocol to determine how the object
> should be reconstructed. It uses this to reconstruct the defaultdict
> with the same default
On Sat, Feb 11, 2012 at 10:54 AM, Ian Kelly wrote:
> class Dog(dict):
>
> def __missing__(self):
> return 0
Sorry, that should have been:
class Dog(dict):
def __missing__(self, key):
return 0
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
I hate being suckered in by trolls, but this paragraph demands a response.
On Mon, Feb 13, 2012 at 9:01 AM, Rick Johnson
wrote:
> You are born with rights. Life, Liberty, and the pursuit of happiness.
> Healthcare care is NOT a right, healthcare is a privileged.
If you deprive a person of access
[Reply sent off-list, partly because this is way off-topic, but also
because python-list rejected my response as spam]
--
http://mail.python.org/mailman/listinfo/python-list
the list do not "bubble up" as they would in bubble sort.
Rather, they jump around somewhat randomly until they are finally
selected for the current sort index. I agree with Arnaud -- this is a
selection sort variant that saves a local variable (the index of the
minimum element) by placing it at the current sort index instead -- at
the cost of doing additional swaps. Probably not a good trade-off in
Python (but then again, no pure Python sort algorithm is likely to
perform better than the built-in).
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Feb 14, 2012 at 11:10 AM, Jabba Laci wrote:
> Hi,
>
>> Either you're misremembering, or the algorithm you programmed 43 years
>> ago was not actually bubble sort. Quoting from Wikipedia:
>>
>> """
>> Bubble sort, also known as sinking sort, is a simple sorting algorithm
>> that works by r
more than 1 element) ?
I believe the behavior in CPython is that if the array is full, the
capacity is doubled, but I'm not certain, and that would be an
implementation detail in any case.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Feb 15, 2012 at 1:12 PM, Rituparna Sengupta wrote:
> Hi,
>
> I'm working on this code and I keep getting an error. It might be some very
> basic thing but I was wondering if someone could help. Its a loop within a
> loop. The part outside the innermost loop gets printed fine, but the par
On Wed, Feb 15, 2012 at 1:28 PM, Dennis Lee Bieber
wrote:
> On Wed, 15 Feb 2012 11:11:27 -0800, Chris Rebert
> wrote:
>
>
>>"The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, …"
>> -- list_resize()
>>
> Rather perverse, is it not? The first set is plain doubling, but
> then yo
ut then I realized that the indirection
allows you to easily sort the cards in the desired order, so that
should be left alone.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
+ value_str[index:]
else:
return value_str + error_str
>>> format_error(1.03789291, 0.00089)
'1.0379(9)'
>>> format_error(103789291, 1000)
'1.03789(1)E+08'
I haven't tested this thoroughly, so use at your own risk. :-)
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
itertools.izip(itertools.cycle(DEALERS),
rotating(VULNERABILITIES)), 16))
But I don't know that it's really worth the added complexity.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Feb 15, 2012 at 8:04 AM, Rick Johnson
wrote:
> I have PROVEN that when people FIGHT back, they will NOT be subjects
> to tyranny; race has NOTHING to do with it. I gave one example in
> history where people would rather die than be subjected to tyranny,
> there are many more. "GIVE ME FREE
wo digits:
>
>>>> format_error( '1.34883', '0.0098' )
> '1.349(10)'
>
> But in this case I'd like to see 1.35(1)
A small adjustment to the scale fixes that. Also tidied up the string
formatting part:
import decimal
def format_error(value, error):
value = decimal.Decimal(value)
error = decimal.Decimal(error)
error_scale = error.adjusted()
error_scale += error.scaleb(-error_scale).to_integral().adjusted()
value_str = str(value.quantize(decimal.Decimal("1E%d" % error_scale)))
error_str = '(%d)' % error.scaleb(-error_scale).to_integral()
if 'E' in value_str:
index = value_str.index('E')
return value_str[:index] + error_str + value_str[index:]
else:
return value_str + error_str
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Feb 16, 2012 at 3:21 PM, Daniel Fetchinson
wrote:
> Thanks, it's simpler indeed, but gives me an error for value=1.267,
> error=0.08:
>
> Traceback (most recent call last):
> File "/home/fetchinson/bin/format_error", line 26, in
> print format_error( sys.argv[1], sys.argv[2] )
> Fil
bang has to be the first thing in the file to be useful. As it
is above, it might as well not be there. I would suggest also
including a doc string in the skeleton.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Feb 17, 2012 at 6:13 PM, Rick Johnson
wrote:
>
> On Mon, Feb 13, 2012 at 7:23 PM, Ian Kelly
> wrote:
>> On Mon, Feb 13, 2012 at 2:01 PM, Rick Johnson
>> I make a middle-class income and do not feel that I am anywhere near
>> being "enslaved" by my in
On Wed, Feb 22, 2012 at 11:13 AM, Alec Taylor wrote:
> Simple mathematical problem, + and - only:
>
1800.00-1041.00-555.74+530.74-794.95
> -60.9500045
>
> That's wrong.
>
> Proof
> http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95
> -60.95 aka (-(1219/20))
>
in sum doesn't do
this. We really don't need to replace it, though. If you want a
different sum behavior, just write your own.
def sum(iterable, *args):
return reduce(operator.add, iterable, *args)
>>> sum([3,4])
7
>>> sum([3,4], 12)
19
>>> sum(['hello', 'world'])
'helloworld'
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
def sum(iterable, start=object()):
if start is sum.func_defaults[0]:
...
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
y)
except EntityNotFound:
pass
closest_object = min(all_entities,
key=lambda e: distance(player.pos, e.pos))
Especially given that all_entities should be reusable in other contexts.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
made it just two seconds ago.
While that's true, if your pickle is untrusted then a ValueError from
unpacking is the least of your worries. You should never attempt to
load an untrusted pickle in the first place, as doing so allows it to
execute arbitrary code on your system.
Cheers,
Ian
--
ions
won't be called until the module is fully imported. It does add some
overhead to the functions, basically the cost of a dict lookup.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
from b
are not going to change that.
Python does some magic so that you can do "import b.c" inside d while
b.c is still importing without resulting in infinite recursion, but
the success of the import does not signify that b.c is actually
available yet.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Feb 27, 2012 at 8:13 PM, Tonico wrote:
> Idiot
Please don't reply to spam. You're just making it show up in the
inboxes of those of us who already have these idiots kill-filed.
--
http://mail.python.org/mailman/listinfo/python-list
called without arguments is equivalent to super(, self) -- it collects the value of self from
the current stack frame. So self is able to be passed in because the
super object implicitly knows what self is.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
rt tags,
end tags, and text, with no guarantee that the tags will actually
correspond in any meaningful way. lxml can be used to output an
actual hierarchical structure that may be easier to manipulate and
extract data from.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Mar 7, 2012 at 12:49 PM, Wanderer wrote:
> I have a list of defective CCD pixels and I need to find clusters
> where a cluster is a group of adjacent defective pixels. This seems to
> me to be a classic linked list tree search.I take a pixel from the
> defective list and check if an adjace
On Wed, Mar 7, 2012 at 1:03 PM, Ian Kelly wrote:
> A set of defective pixels would be the probable choice, since it
> offers efficient membership testing.
Some actual code, using a recursive generator:
def get_cluster(defective, pixel):
yield pixel
(row, column) = pixel
for ad
On Wed, Mar 7, 2012 at 1:39 PM, John Salerno wrote:
> Ok, first major roadblock. I have no idea how to install Beautiful
> Soup or lxml on Windows! All I can find are .tar files. Based on what
> I've read, I can use the easy_setup module to install these types of
> files, but when I went to downlo
On Wed, Mar 7, 2012 at 2:11 PM, John Salerno wrote:
> The only files included in the .tar.gz file is a .tar file of the same
> name. So I guess the setup option doesn't exist for these particular
> packages.
The setup.py file (as well as the other files) would be inside the
.tar file. Unlike a W
On Sat, Mar 10, 2012 at 6:17 AM, Günther Dietrich
wrote:
> In article
> <46758542-1bd6-43fe-8e80-bcf14b7d8...@pi6g2000pbc.googlegroups.com>,
> sl33k wrote:
>
>>I'm trying project euler problem 3 and I've hit the wall with this
>>error. What could be the problem here?
>>
>> l=[]
> num=6008514
(C): pass
In Python 3, classic classes have been removed, and so all four of the
classes above would be new-style.
> 2. Is the mro function available only on python3?
No, but it is available only on new-style classes. If you try it on a
classic class, you'll get an AttributeError.
On Sun, Mar 11, 2012 at 5:40 AM, Ian Kelly wrote:
>> 2. Is the mro function available only on python3?
>
> No, but it is available only on new-style classes. If you try it on a
> classic class, you'll get an AttributeError.
And by the way, you probably shouldn't cal
On Tue, Mar 13, 2012 at 8:35 AM, ferreirafm wrote:
> Hi List,
> I've coded three functions that I would like to concatenate. I mean, run
> them one after another. The third function depends on the results of the
> second function, which depends on the results of the first one. When I call
> one fu
int, the type
should be int? And even if you manage to get the inference working
flawlessly and expectedly for append, what about custom actions?
It seems to me that there are a large number of edge cases here that
will end up hurting predictability for the end user.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
his:
class MyDialog(wx.Dialog):
name = TextDescriptor('_name')
description = TextDescriptor('_description')
address = TextDescriptor('_address')
def __init__(self, ...):
# Build the dialog along with the _name, _description, and
_address controls...
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Mar 15, 2012 at 1:10 PM, Prasad, Ramit
wrote:
>> Prasad, Ramit wrote:
>>
>> > So I have a context manager used to catch errors
>> >
>> > def __exit__( self, exceptionClass, exception, tracebackObject ):
>> > if isinstance( exception, self.exceptionClasses ):
>> > #do something
On Thu, Mar 15, 2012 at 2:25 PM, Prasad, Ramit
wrote:
>> > ...
>> > (, "'A' object has no attribute 'x'",
>> )
>> > AttributeError: 'A' object has no attribute 'x'
>> >
>> > As you can see, I am
On Fri, Mar 16, 2012 at 10:45 AM, Steven D'Aprano
wrote:
> On Fri, 16 Mar 2012 17:31:06 +0100, Kiuhnm wrote:
>
>> You wouldn't, because Haskel's way is more regular and makes a lot of
>> sense: parentheses are for grouping and that's it.
>
> If f is a function which normally takes (for the sake of
ement and doesn't import the dependencies..
> Any hints?
You didn't actually monkey-patch it. You just created a local called
__import__ that stores a wrapped version of the function. You need to
actually replace it in the __builtin__ module:
import __builtin__
__builtin__.__import__ = my_import
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
cls.__dict__ at line(#ref3).
No, type.__new__ does not call type.__init__ at all. Rather, it is
type.__new__ that is responsible for copying the dict, not
type.__init__. For this reason you should override type.__new__ in
your metaclass, not type.__init__.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
ames "cur" and "curr" are terrible. Good names should describe
what the function does without being too onerous to type, and the
addition of the duplicate "r" is not an obvious mnemonic for
remembering that the first one prohibits duplicate keyword arguments
and the second one allows them. Why not more descriptive names like
"curry" and "curry_unique"?
That's all I've got. All in all, it's pretty decent for a Python newbie.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
second iterator, however, is recreated on
every iteration of the first iterator, so it can't be pre-built in
that manner. It does get created in the generator scope, and when
that happens it blows up because it can't find the variable, just like
the function example above.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Mar 22, 2012 at 1:48 PM, Rodrick Brown wrote:
> Why wasnt the t removed ?
Because str.strip() only removes leading or trailing characters. If
you want to remove all the t's, use str.replace:
'this is a test'.replace('t', '')
Cheers,
Ian
--
h
701 - 800 of 3945 matches
Mail list logo