On Wed, Dec 5, 2012 at 7:34 AM, Neil Cerutti wrote:
> Well, shoot! Then this is a job for groupby, not takewhile.
The problem with groupby is that you can't just limit it to two groups.
>>> prod_desc("CAPSICUM RED fresh from QLD")
['QLD', 'fresh from']
Once you've got a false key from the group
On Wed, Dec 5, 2012 at 6:45 AM, Chris Angelico wrote:
> On Wed, Dec 5, 2012 at 12:17 PM, Nick Mellor wrote:
>>
>> takewhile mines for gold at the start of a sequence, dropwhile drops the
>> dross at the start of a sequence.
>
> When you're using both over the same sequence and with the same
> co
On Wed, Dec 5, 2012 at 10:34 AM, Steven D'Aprano
wrote:
> The difference is almost certain between the LOAD_CONST and the
> LOAD_GLOBAL.
>
> As to *why* there is such a difference, I believe that's a leftover from
> early Python days when None was not a keyword and could be reassigned.
I think th
On Wed, Dec 5, 2012 at 11:18 AM, Ian Kelly wrote:
> On Wed, Dec 5, 2012 at 10:57 AM, Daniel Doo
> wrote:
>> I am new to Python. Is there a method to “join” two pipe delimited files
>> using a unique key that appears in both files? I would like to implement
>> somet
On Wed, Dec 5, 2012 at 10:57 AM, Daniel Doo
wrote:
> I am new to Python. Is there a method to “join” two pipe delimited files
> using a unique key that appears in both files? I would like to implement
> something similar to the Unix join command.
If the files are small enough to fit in virtual
On Wed, Dec 5, 2012 at 9:48 AM, rh wrote:
> I have argparse working with one exception. I wanted the program to print out
> usage when no command line options are given. But I only came across
> other examples where people didn't use argparse but instead printed out
> a separate usage statement. S
On Wed, Dec 5, 2012 at 8:03 PM, Joseph L. Casale
wrote:
> I get a list of dicts as output from a source I need to then extract various
> dicts
> out of. I can easily extract the dict of choice based on it containing a key
> with
> a certain value using list comp but I was hoping to use dict comp
On Thu, Dec 6, 2012 at 11:03 PM, INADA Naoki wrote:
> The reference says:
>
> The truth of x==y does not imply that x!=y is false.
> Accordingly, when defining __eq__(), one should also
> define __ne__() so that the operators will behave as expected.
>
> (http://docs.python.org/3/reference/d
On Fri, Dec 7, 2012 at 12:41 AM, Markus Christen
wrote:
> good morning
>
> i am using pyodbc 3.0.6 for win32 python 2.7.3
> i used it to connect with a MsSql db. Now i have a little problem with the
> umlaut. i cant change anything in the db and there are umlauts like "ä", "ö"
> and "ü" saved. s
On Sat, Dec 8, 2012 at 2:32 PM, Graham Fielding wrote:
> Hey, all!
>
> I've managed to get my project to a semi-playable state (everything
> functions, if not precisely the way I'd like it to). One small issue is
> that when the player movs from one level to the next, the items and monsters
> in
On Mon, Dec 10, 2012 at 8:48 PM, Dave Cinege wrote:
> Thesaurus: A different way to call a dictionary.
>
> Thesaurus is a new a dictionary subclass which allows calling keys as
> if they are class attributes and will search through nested objects
> recursively when __getitem__ is called.
>
> You w
On Tue, Dec 11, 2012 at 1:57 PM, Dave Cinege wrote:
> On Tuesday 11 December 2012 01:41:38 Ian Kelly wrote:
>> Second, in __getitem__ you start a loop with "for i in
>> range(len(l)):", and then you use i as an index into l several times.
>> It would be cleaner
On Tue, Dec 11, 2012 at 2:53 PM, Ian Kelly wrote:
> and then I ran the examples, and the output was unchanged. As Steven
> pointed out, I don't see how that first branch could succeed anyway,
> since self.data is never defined.
It occurs to me that the UserDict class does have a
On Wed, Dec 12, 2012 at 10:22 AM, wrote:
> Well, I did some modifications and got a hollow square, but the columns
> aren't perfectly aligned with the rows (at least if input is 5. Thanks for
> the help :)
>
> rows = int(input())
> s1="* "*rows
> s2="*"+(rows-2)*" "+"*"
> print(s1)
> for s in r
On Wed, Dec 12, 2012 at 12:20 PM, Dave Cinege wrote:
> On Tuesday 11 December 2012 01:41:38 Ian Kelly wrote:
>
>> I have a few critiques on the code. First, you might want to use
>> __getattribute__ instead of __getattr__. Otherwise you'll end up
>
> File
On Wed, Dec 12, 2012 at 1:53 PM, MRAB wrote:
> You could try a non-blocking semaphore:
>
> def __init__(self):
> self.cameraActive = Semaphore()
Why a Semaphore and not just a plain old Lock?
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Dec 12, 2012 at 3:20 PM, Dave Cinege wrote:
> On Wednesday 12 December 2012 15:42:36 Ian Kelly wrote:
>
>> def __getattribute__(self, name):
>> if name.startswith('__') and name.endswith('__'):
>> return super(Thesaurus, sel
On Thu, Dec 13, 2012 at 3:26 AM, Alexander Blinne wrote:
> I have a general question about this kinds of things. I see that the
> above is a common use case for some kind of lock which does this
> testing/locking atomically. But the question is: if I know for sure that
> there is no other thread t
On Thu, Dec 13, 2012 at 1:39 PM, Daniel Fetchinson
wrote:
>> If you know the sequence has at least n items, you
>> can do a, b, c = seq[:3]
>
> Yeah, that's probably the simplest, without all the fancy stuff :)
That only works for sequences, though. Not all iterables are
sequences. The islice v
On Sun, Dec 16, 2012 at 10:32 AM, Kwpolska wrote:
> On Sun, Dec 16, 2012 at 6:25 PM, wrote:
>> On Sunday, December 16, 2012 10:09:53 AM UTC-7, Kwpolska wrote:
>>>[...]
>>> PS. please do not use pastebin.com.
>>
>> Why?
>
> http://news.ycombinator.com/item?id=2595066 should answer this very quest
On Sun, Dec 16, 2012 at 9:30 PM, Nick M. Daly wrote:
> It's very unlikely that multiple inheritance would go horribly wrong, as
> long as classes adopt class-specific argument naming conventions.
> However, ever since bug 1683368 [0] was fixed, it's now impossible to
> cleanly create arbitrary inh
On Wed, Dec 19, 2012 at 8:40 AM, Chris Angelico wrote:
> You may not be familiar with jmf. He's one of our resident trolls, and
> he has a bee in his bonnet about PEP 393 strings, on the basis that
> they take up more space in memory than a narrow build of Python 3.2
> would, for a string with lot
On Wed, Dec 19, 2012 at 1:55 PM, wrote:
> Yes, it is correct (or can be considered as correct).
> I do not wish to discuss the typographical problematic
> of "Das Grosse Eszett". The web is full of pages on the
> subject. However, I never succeeded to find an "official
> position" from Unicode. T
On Wed, Dec 19, 2012 at 2:18 PM, wrote:
> latin-1 (iso-8859-1) ? are you sure ?
Yes.
sys.getsizeof('a')
> 26
sys.getsizeof('ab')
> 27
sys.getsizeof('aé')
> 39
Compare to:
>>> sys.getsizeof('a\u0100')
42
The reason for the difference you posted is that pure ASCII strings
have a
On Wed, Dec 19, 2012 at 5:07 PM, Terry Reedy wrote:
> That says that my browser, Firefox 17, does not support HTML5. Golly gee. I
> don't think any browser support5 all of that moving target, and Gecko
> apparently supports about as large a subset as most.
> https://en.wikipedia.org/wiki/Compariso
On Thu, Dec 20, 2012 at 5:50 AM, wrote:
> Brought my laptop out of hibernation to do some work this morning. I
> attempted to run one of my ETLs and got the following error. I made no
> changes since it was running yesterday.
>
>
>
> [swright@localhost app]$ python etl_botnet_meta.py --mode dev
On Thu, Dec 20, 2012 at 12:19 PM, wrote:
> The first (and it should be quite obvious) consequence is that
> you create bloated, unnecessary and useless code. I simplify
> the flexible string representation (FSR) and will use an "ascii" /
> "non-ascii" model/terminology.
>
> If you are an "ascii"
On Fri, Dec 21, 2012 at 9:16 AM, Pierre Quentel
wrote:
>> <= is a comparison expression operator, which is completely different.
>> It is just wrong for this usage. I am 99.9% sure you will come to regret
>> it eventually. Better to make the change now than in Brython2 or Brython3.
>
> I am 99.99%
On Fri, Dec 21, 2012 at 1:59 PM, Pierre Quentel
wrote:
>> By the way, what is Brython actually doing when you append a child to
>> the document itself like that? Usually I would expect a div to be
>> appended to the body or to another div. The above looks like it would
>> attach the new div as a
On Fri, Dec 21, 2012 at 3:52 PM, Chris Angelico wrote:
> On Sat, Dec 22, 2012 at 3:36 AM, Pierre Quentel
> wrote:
>>
>>> Hmm. So when that gets added into a DIV, it has to get parsed for
>>> tags? How does this work? This seems very odd. I would have expected
>>> it to remain as DOM objects.
>>
>
On Fri, Dec 21, 2012 at 4:45 PM, Ian Kelly wrote:
> In Brython, the str builtin does not return strings?
Oh, and repr is just a synonym of str, which makes it useless.
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Dec 21, 2012 at 4:45 PM, Ian Kelly wrote:
> In my playing around with it just now, the addition doesn't seem to
> actually return a string.
>From the code, it appears that adding two nodes together *actually*
returns a $AbstractTag object, which seems to be just a container
On Sat, Dec 22, 2012 at 1:31 PM, Dan Sommers wrote:
> So why are we all so comfortable with using "*" as the operator for
> multiplication? I'm sure that a new programming language that dared to
> use U+00D7 or U+2715 for multiplication would be instantly rejected on
> the grounds that it was con
On Dec 24, 2012 9:37 AM, "Pander Musubi" wrote:
> > >>> ''.join(sorted(random.sample(cs, 20), key=d.get))
> >
> > '5aAàÀåBCçËÉíÎLÖøquùx'
>
> This doesn't work for words with more than one character:
Try this instead:
def collate(x):
return list(map(d.get, x))
sorted(data, key=collate)
I w
On Tue, Dec 25, 2012 at 8:40 PM, Ramchandra Apte wrote:
> On Monday, 24 December 2012 08:08:12 UTC+5:30, Robert Montgomery wrote:
>> I am writing a script that will send an email using an account I set up
>>
>> in gmail. It is an smtp server using tls on port 587, and I would like
>>
>> to use a
On Wed, Dec 26, 2012 at 4:21 PM, wrote:
> Thank you very much for your reply. I actually just deleted this post as you
> were replying! I had figured out a few things and then got confused about a
> few others :/ If you have a chance, can you look at the other post? Thank
> you!!
You can'
On Thu, Dec 27, 2012 at 7:44 AM, Joseph L. Casale
wrote:
> I am writing a class to provide a db backed configuration for an application.
>
> In my programs code, I import the class and pass the ODBC params to the
> class for its __init__ to instantiate a connection.
>
> I would like to create a fu
On Thu, Dec 27, 2012 at 11:50 AM, Steven W. Orr wrote:
> Really? I thought that the whole idea of using "rb" or "wb" was something
> that was necessitated by WinBlo$e. We're not doing IO on a text file here.
> It's a tar file which by definition is binary and it's not clear to me why
> unicode has
On Thu, Dec 27, 2012 at 12:25 PM, Ian Kelly wrote:
> You're correct that it makes no sense to open a tar file in binary
> mode,
Of course that should have read: "it makes no sense to open a tar file
in text mode."
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Dec 27, 2012 at 1:16 PM, Joseph L. Casale
wrote:
> When you use optional named arguments in a function, how do you deal with with
> the incorrect assignment when only some args are supplied?
>
> If I do something like:
>
> def my_func(self, **kwargs):
>
> then handle the test cases wit
On Thu, Dec 27, 2012 at 1:47 PM, Joseph L. Casale
wrote:
>> Don't use kwargs for this. List out the arguments in the function
>> spec and give the optional ones reasonable defaults.
>
>> I only use kwargs myself when the set of possible arguments is dynamic
>> or unknown.
>
> Gotch ya, but when t
On Thu, Dec 27, 2012 at 3:17 PM, Terry Reedy wrote:
>> PS Py 3.3 warranty: ~30% slower than Py 3.2
>
>
> Do you have any actual timing data to back up that claim?
> If so, please give specifics, including build, os, system, timing code, and
> result.
There was another thread about this one a whil
On Thu, Dec 27, 2012 at 5:33 PM, Gnarlodious wrote:
> Graham Dumpleton has informed me that the the relevant bug reports are:
>
> http://bugs.python.org/issue8098
> http://bugs.python.org/issue9260
>
> To quote:
>
> All the problems derive from a stupid function in Python internals called
> PyImp
On Wed, Jan 2, 2013 at 7:32 AM, Chris Angelico wrote:
> Okay, I have to ask... why? Does it have an exception for names of classes?
Yes, and for module-level functions.
> I don't like linters that enforce too much style. Catch things that
> might be mis-coded (like C's classic "if (x = 1)"), but
On Wed, Jan 2, 2013 at 10:57 AM, Chris Angelico wrote:
> Yeah, same applies to most linters I think. You end up disagreeing
> with the author on half the points. Oh well. Doesn't make the tool
> useless, just means you need to fiddle with it to get it how you want
> it.
It's a lot less work to di
On Wed, Jan 2, 2013 at 4:52 PM, Steven D'Aprano
wrote:
> If pylint says that global variables should be named like "__variable__",
> that is explicitly going against PEP 8.
It doesn't say that anywhere. It includes dunder names in the regex
so that you don't get spurious warnings from pylint abo
On Wed, Jan 2, 2013 at 7:24 PM, someone wrote:
> 1) class somethingWork: Invalid name "somethingWork" (should match
> [A-Z_][a-zA-Z0-9]+$), I'm not that good at regular exps, but I suppose it
> wants my class name to start with a capital letter ?
Yes, PEP-8 recommends CamelCase for class names.
On Thu, Jan 3, 2013 at 2:27 AM, Andrew Berg wrote:
> Does 'from __future__ import barry_as_FLUFL' do anything? Despite PEP
> 401, using print as a statement still raises a SyntaxError.
I think it only replaces the != operator with <>.
> Where is 'from __future__ import braces' implemented in CPy
On Sat, Jan 5, 2013 at 8:57 AM, Chris Angelico wrote:
> You miss my point, though. I went for simple Pythonic code, and never
> measured its performance, on the expectation that it's "good enough".
> Written in C, the state machine is probably WAY faster than splitting
> and then iterating. My C++
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
>
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
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
On Mon, Jan 23, 2012 at 9:41 AM, Giampaolo Rodolà wrote:
>
> Il 21 gennaio 2012 22:13, Erik Max Francis ha scritto:
> > The real reason people still use the `while 1` construct, I would imagine,
> > is just inertia or habit, rather than a conscious, defensive decision. If
> > it's the latter, it
On Mon, Jan 23, 2012 at 12:44 PM, Jonno wrote:
> I have a pretty complicated bit of code that I'm trying to convert to more
> clean OOP.
Then you probably should not be using globals.
> Without getting too heavy into the details I have an object which I am
> trying to make available inside anoth
On Mon, Jan 23, 2012 at 1:58 PM, MRAB wrote:
>> Either way would work but the main issue is I can't seem to use foo or
>> foo.bar or foo.bar.object anywhere in __init__ or even before that in
>> the main class area.
>>
> This line:
>
> foo = MyApp(0)
>
> will create a 'MyApp' instance and then bin
On Mon, Jan 23, 2012 at 2:22 PM, Jonno wrote:
>> References inside functions are resolved when the function is called. So
>> purely from what you have presented above, it would seem that 'foo' is
>> defined between the call to __init__ and a later call to method1.
>
>
> I have a strong suspicion t
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
>>
On Mon, Jan 23, 2012 at 3:45 PM, Jonno wrote:
> I see, so that would get me access to the app instance during init of Class1
> but if I can't access frame or the object as they still aren't created yet.
> I can only do that in attributes that I know won't be called until the app
> is created.
Yea
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
On Wed, Jan 25, 2012 at 10:16 AM, Rick Johnson
wrote:
> (?...) # Base Extension Syntax
> All extensions are wrapped in parenthesis and start with a question
> mark, but i believe the question mark was a very bad choice, since the
> question mark is already specific to "zero or one repetitions of
On Wed, Jan 25, 2012 at 1:14 PM, Rick Johnson
wrote:
> Wow, why i am not surprised! Let's pick one usage at random and try to
> understand it. "I think XYZ is pretty easy." You don't even need
> "pretty" to get your point across. You could simply say "I think XYZ
> is easy".
But "easy" and "prett
On Wed, Jan 25, 2012 at 2:19 PM, Rick Johnson
wrote:
> I disagree here.
> Whist some people may be "die-hard" fans of the un-intuitive perl
> regex syntax, i believe many, if not exponentially MORE people would
> like to have a better alternative. Do i want to remove the current
> "well establishe
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
On Wed, Jan 25, 2012 at 10:25 PM, rusi wrote:
> The contents of this thread ostensibly argues about the word 'pretty'
> Actually it seems to be arguing about the word 'troll'
>
> Every other post calls the OP a troll and then outdoes his post in
> length.
I just grepped, and it's hardly "every ot
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.
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 walk through the tuples until it finds a match.
>
> Is this absolutely guaranteed? The C API
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
On Tue, Jan 31, 2012 at 5:54 PM, Emmanuel Mayssat wrote:
> I have the following program.
> I am trying to have index the attributes of an object using __getitem__.
> Reading them this way works great, but assigning them a value doesn't
> Is there a way to do such a thing?
For assignment, use __se
On Wed, Feb 1, 2012 at 11:47 AM, Mel Wilson wrote:
> I guess they want local symbols in functions to be pre-compiled. Similar to
> the way you can't usefully update the dict returned by locals(). Strangely,
> I notice that
>
> Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
> [GCC 4.4.3] on lin
On Wed, Feb 1, 2012 at 3:24 PM, Ethan Furman wrote:
> Definitely should rely on it, because in CPython 3 exec does not un-optimize
> the function and assigning to locals() will not actually change the
> functions variables.
Well, the former is not surprising, since exec was changed from a
stateme
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())
> ...
> -->
> -->
On Thu, Feb 2, 2012 at 3:53 PM, andrea crotti wrote:
> 2012/2/2 Amirouche Boubekki :
>> They are solution to write Python code that translates to javascript see
>> this thread
>> http://mail.python.org/pipermail/python-list/2011-November/1283110.html
>>
>
> Mm I don't think it's what the OP is ask
On Sat, Feb 4, 2012 at 9:19 PM, Antti J Ylikoski wrote:
>> I'm not sure how naughty this is, but the same thing can be done without
>> using
>> nonlocal by storing the local state as an attribute of the enclosed
>> function
>> object:
>>
>> ...
>
> Yes, I do know that, but then it would not be a c
On Tue, Feb 7, 2012 at 5:27 AM, Sammy Danso wrote:
>
> Hello experts,
> I am having trouble accessing the content of my list.
> my list content has 2-pair value with the exception of one which has single
> value. here is an example ['a', 1, 'b', 1, 'c', 3, 'd']
>
> I am unable to iterate through
On Wed, Feb 8, 2012 at 6:23 PM, Evan Driscoll wrote:
> Hi all,
>
> I've been trying for a few days (only a little bit at a time) to come up
> with a way of implementing a frozendict that doesn't suck. I'm gradually
> converging to a solution, but I can't help but think that there's some
> subtlety
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
On Thu, Feb 9, 2012 at 8:36 PM, MRAB wrote:
> On 10/02/2012 02:25, noydb wrote:
>>
>> That {>>> (3219 + 99) // 100} doesnt work if the number is other then
>> 4 digits.
>>
>>
>> (for rounding up to nearest 100):
>
> (3219 + 99)//100
>>
>> 33
>
> (3289 + 99)//100
>>
>> 33
>
>
On Fri, Feb 10, 2012 at 1:04 PM, Thomas Philips wrote:
> In the past, when deleting items from a list, I looped through the
> list in reverse to avoid accidentally deleting items I wanted to keep.
> I tried something different today, and, to my surprise, was able to
> delete items correctly, regar
501 - 600 of 3558 matches
Mail list logo