On Mon, Oct 29, 2012 at 1:36 PM, Chris Angelico wrote:
> Question: Is it clearer to take advantage of the fact that the base
> class can be an arbitrary expression?
>
> class MyImmutableClass(namedtuple('MyImmutableClass', 'field1 field2
> field3 field4')):
>
> You lose the unnecessary temporary a
On Mon, Oct 29, 2012 at 9:20 AM, Andrew Robinson
wrote:
> FYI: I was asking for a reason why Python's present implementation is
> desirable...
>
> I wonder, for example:
>
> Given an arbitrary list:
> a=[1,2,3,4,5,6,7,8,9,10,11,12]
>
> Why would someone *want* to do:
> a[-7,10]
> Instead of saying
On Mon, Oct 29, 2012 at 9:42 AM, Andrew Robinson
wrote:
> The list was generated in a single pass by many .append() 's, and then
> copied once -- the original was left in place; and then I attempted to slice
> it.
Note that if the list was generated by .appends, then it was copied
more than once.
On Mon, Oct 29, 2012 at 5:24 PM, Roy Smith wrote:
> I think you're missing the point of "amortized constant time". Yes, the
> first item appended to the list will be copied lg(20,000,000) ~= 25
> times, because the list will be resized that many times(*). But, on
> average (I'm not sure if "aver
On Mon, Oct 29, 2012 at 5:43 PM, Ian Kelly wrote:
> The growth factor is approximately 1.125. "Approximately" because
> there is also a small constant term. The average number of copies per
> item converges on 8.
Of course, that is the *maximum* number of copies. The act
On Mon, Oct 29, 2012 at 12:00 PM, Andrew Robinson
wrote:
> I downloaded the source code for python 3.3.0, as the tbz;
> In the directory "Python-3.3.0/Python", look at Python-ast.c, line 2089 &
> ff.
Python-ast.c is part of the compiler code. That's not the struct used
to represent the object at
On Mon, Oct 29, 2012 at 4:39 PM, Andrew Robinson
wrote:
> In addition to those items you mention, of which the reference count is not
> even *inside* the struct -- there is additional debugging information not
> mentioned. Built in objects contain a "line number", a "column number", and
> a "cont
On Mon, Oct 29, 2012 at 7:49 PM, Chris Kaynor wrote:
> NOTE: The above is taken from reading the source code for Python 2.6.
> For some odd reason, I am getting that an empty tuple consists of 6
> pointer-sized objects (48 bytes on x64), rather than the expected 3
> pointer-sized (24 bytes on x64)
On Mon, Oct 29, 2012 at 6:17 PM, Andrew Robinson
wrote:
> If you re-check my post to chris, I listed the struct you mention.
> The C code is what is actually run (by GDB breakpoint test) when a tuple is
> instantiated.
When you were running GDB, were you debugging the interactive
interpreter or a
On Mon, Oct 29, 2012 at 5:54 PM, Andrew Robinson
wrote:
>> I don't know of a reason why one might need to use a negative start
>> with a positive stop, though.
>
> I've already given several examples; and another poster did too
I meant that I don't know of a reason to do that given the existing
s
On Tue, Oct 30, 2012 at 1:21 AM, Ian Kelly wrote:
> I'm not entirely certain why collection objects get this special
> treatment, but there you have it.
Thinking about it some more, this makes sense. The GC header is there
to support garbage collection for the object. Atomic types l
On Tue, Oct 30, 2012 at 7:41 AM, Ethan Furman wrote:
> class Spam():
> @staticmethod
> def green():
> print('on a train!')
> @staticmethod
> def question():
> print('would you, could you', end='')
> Spam.green()
>
> It can be a pain if you change the class n
On Tue, Oct 30, 2012 at 10:14 AM, Ethan Furman wrote:
> File a bug report?
Looks like it's already been wontfixed back in 2006:
http://bugs.python.org/issue1501180
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Oct 30, 2012 at 3:33 PM, Mark Lawrence wrote:
> On 30/10/2012 18:02, Ian Kelly wrote:
>>
>> On Tue, Oct 30, 2012 at 10:14 AM, Ethan Furman wrote:
>>>
>>> File a bug report?
>>
>>
>> Looks like it's already been wontfixed
On Tue, Oct 30, 2012 at 8:21 AM, Andrew Robinson
wrote:
> D'Apriano mentioned the named values, start, stop, step in a slice() which
> are an API and legacy issue; These three names must also be stored in the
> interpreter someplace. Since slice is defined at the "C" level as a struct,
> have yo
On Tue, Oct 30, 2012 at 3:55 PM, Ian Kelly wrote:
> On Tue, Oct 30, 2012 at 8:21 AM, Andrew Robinson
> wrote:
>> D'Apriano mentioned the named values, start, stop, step in a slice() which
>> are an API and legacy issue; These three names must also be stored in the
&
On Tue, Oct 30, 2012 at 4:25 PM, Andrew Robinson
wrote:
> Ian,
>
>> Looks like it's already been wontfixed back in 2006:
>
>> http://bugs.python.org/issue1501180
>
> Absolutely bloody typical, turned down because of an idiot. Who the hell is
> Tim Peters anyway?
>
>> I don't really disagree with
On Wed, Oct 31, 2012 at 9:17 AM, djc wrote:
> The best I can think of is to split the input sequence into two lists, sort
> each and then join them.
In the example you have given they already seem to be split, so you
could just do:
sorted(n, key=int) + sorted(s)
If that's not really the case, t
On Wed, Oct 31, 2012 at 7:42 AM, Andrew Robinson
wrote:
> Then; I'd note: The non-goofy purpose of slice is to hold three data
> values; They are either numbers or None. These *normally* encountered
> values can't create a memory loop.
> So, FOR AS LONG, as the object representing slice does no
On Wed, Oct 31, 2012 at 3:33 PM, Mark Lawrence wrote:
> Nope. I'm busy porting my own code from 2.7 to 3.3 and cmp seems to be
> very dead.
>
> This doesn't help either.
>
> c:\Users\Mark\Cash\Python>**2to3.py
>
> Traceback (most recent call last):
> File "C:\Python33\Tools\Scripts\**2to3.py",
On Thu, Nov 1, 2012 at 9:32 AM, inshu chauhan wrote:
> what is the most pythonic way to do this :
>
>if 0 < ix < 10 and 0 < iy < 10 ???
>
I suppose you could do
if all(0 < i < 10 for i in (ix, iy)):
but I think that the original is more readable unless you have several
On Thu, Nov 1, 2012 at 5:32 AM, Andrew Robinson
wrote:
> H was that PEP the active state of Python, when Tim rejected the bug
> report?
Yes. The PEP was accepted and committed in March 2006 for release in
Python 2.5. The bug report is from June 2006 has a version
classification of Pytho
On Thu, Nov 1, 2012 at 3:38 PM, Andrea Crotti wrote:
> What I would like to write is
> @lazy_property
> def var_lazy(self):
> return long_computation()
>
> and this should imply that the long_computation is called only once..
If you're using Python 3.2+, then functools.lru_cache p
On Tue, Oct 9, 2012 at 5:51 PM, Steven D'Aprano
wrote:
> On Tue, 09 Oct 2012 11:08:13 -0600, Ian Kelly wrote:
>
>> I tend to view name mangling as being more for avoiding internal
>> attribute collisions in complex inheritance structures than for
>> designating na
On Thu, Nov 1, 2012 at 4:25 PM, Andrew Robinson
wrote:
> The bottom line is: __getitem__ must always *PASS* len( seq ) to slice()
> each *time* the slice() object is-used. Since this is the case, it would
> have been better to have list, itself, have a default member which takes the
> raw slice
On Fri, Nov 2, 2012 at 3:36 AM, Jamie Paul Griffin wrote:
> / ru...@yahoo.com wrote on Thu 1.Nov'12 at 15:08:26 -0700 /
>
>> On 11/01/2012 03:55 AM, Jamie Paul Griffin wrote:
>> > Anybody serious about programming should be using a form of
>> > UNIX/Linux if you ask me. It's inconceivable that th
On Fri, Nov 2, 2012 at 1:19 PM, wrote:
> Is there anything anyone could recommend to make it more "Pythonic" or more
> functional. It looks clumsy next to the Haskell.
def options(heaps):
for i, heap in enumerate(heaps):
head = heaps[:i]
tail = heaps[i+1:]
yield fro
On Fri, Nov 2, 2012 at 3:40 PM, Ian Kelly wrote:
> On Fri, Nov 2, 2012 at 1:19 PM, wrote:
>> Is there anything anyone could recommend to make it more "Pythonic" or more
>> functional. It looks clumsy next to the Haskell.
>
> def options(heaps):
>
On Fri, Nov 2, 2012 at 4:24 PM, Dave Angel wrote:
> Perhaps range(heap) should be replaced by range(len(heap))
"heaps" is a list of ints per the OP, so "heap" is an int.
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, Nov 4, 2012 at 11:39 AM, Mark Lawrence wrote:
> Anybody serious about programming should know that an OS is a combination
> of the hardware and software. Can the *Nix variants now do proper
> clustering or are they still decades behind VMS? Never used the other
> main/mini frame systems
On Tue, Nov 6, 2012 at 1:21 AM, Andrew Robinson
wrote:
> If you nest it another time;
> [[[None]]]*4, the same would happen; all lists would be independent -- but
> the objects which aren't lists would be refrenced-- not copied.
>
> a=[[["alpha","beta"]]]*4 would yield:
> a=[[['alpha', 'beta']], [
On Tue, Nov 6, 2012 at 8:03 AM, wrote:
> I've used angle brackets just for posting here,becauze this forum doesn't
> support [code][/code]
This is a Usenet group, not a web forum.
> Just got answer, I didn't call a class it's self. Correct code is:
> class derivedClass(baseClassMod.baseClass)
On Tue, Nov 6, 2012 at 2:36 PM, Andrew Robinson
wrote:
> I meant all lists are shallow copied from the innermost level out.
> Equivalently, it's a deep copy of list objects -- but a shallow copy of any
> list contents except other lists.
Why only list objects, though? When a user writes [[]] *
On Tue, Nov 6, 2012 at 3:41 PM, Andrew Robinson
wrote:
>> Q: What about other mutable objects like sets or dicts?
>> A: No, the elements are never copied.
>
> They aren't list multiplication compatible in any event! It's a total
> nonsense objection.
>
> If these are inconsistent in my i
On Wed, Nov 7, 2012 at 9:07 AM, Devashish Tyagi
wrote:
> So I want to store the current state of a InteractiveInterpreter Object in
> database. In order to achieve this I tried this
>
> obj = InteractiveInterpreter()
> local = obj.locals()
> pickle.dump(local, open('obj.dump','rw'))
>
> But I rec
On Wed, Nov 7, 2012 at 9:16 AM, Ian Kelly wrote:
> On Wed, Nov 7, 2012 at 9:07 AM, Devashish Tyagi
> wrote:
>> So I want to store the current state of a InteractiveInterpreter Object in
>> database. In order to achieve this I tried this
>>
>> obj = InteractiveInter
On Wed, Nov 7, 2012 at 10:40 AM, Devashish Tyagi
wrote:
> Here is the code
>
> from code import InteractiveInterpreter
> import StringIO
> import pickle
>
> src = StringIO.StringIO()
> inter = InteractiveInterpreter()
> inter.runcode('a = 5')
> local = inter.locals
>
> pickle.dump(local,open('obj.
On Wed, Nov 7, 2012 at 12:51 PM, Andrew Robinson
wrote:
> Interesting, you avoided the main point "lists are copied with list
> multiplication".
It seems that each post is longer than the last. If we each responded
to every point made, this thread would fill a book.
Anyway, your point was to su
On Wed, Nov 7, 2012 at 3:02 PM, Andrew Robinson
wrote:
> Draw up some use cases for the multiplication operator (I'm calling on your
> experience, let's not trust mine, right?); What are all the Typical ways
> people *Do* to use it now?
>
> If those use cases do not *primarily* center around *wan
On Wed, Nov 7, 2012 at 8:13 PM, Andrew Robinson
wrote:
> OK, and is this a main use case? (I'm not saying it isn't I'm asking.)
I have no idea what is a "main" use case.
> There is a special keyword which signals the new type of comprehension; A
> normal comprehension would say eg: '[ foo for
On Thu, Nov 8, 2012 at 12:09 AM, Nikhil Verma wrote:
> What i want to know is if i convert it to
>
> date_object = datetime.strptime(' Friday November 9 2012 11:30PM', '%u %B %d
> %Y %I:%M%p' )
>
> It is giving me ValueError saying u is unsupported directive !
Use '%A' to match 'Friday', not '%u'
On Thu, Nov 8, 2012 at 1:26 AM, Andrew Robinson
wrote:
> OK: Then copy by reference using map:
>
> values = zip( map( lambda:times, xrange(num_groups) ) )
> if len(values) < len(times) * num_groups ...
>
> Done. It's clearer than a list comprehension and you still really don't
> need a li
On Thu, Nov 8, 2012 at 8:55 AM, Ulrich Eckhardt
wrote:
> Hi!
>
> Preparing for an upgrade from 2.7 to 3, I stumbled across an incompatibility
> between 2.7 and 3.2 on one hand and 3.3 on the other:
>
> class X(int):
> def __init__(self, value):
> super(X, self).__init__(value)
> X(42)
On Thu, Nov 8, 2012 at 10:30 AM, Andriy Kornatskyy
wrote:
>
> People who come from strongly typed languages that offer interfaces often are
> confused by lack of one in Python. Python, being dynamic typing programming
> language, follows duck typing principal. It can as simple as this:
>
> asser
On Thu, Nov 8, 2012 at 11:32 AM, Oscar Benjamin
wrote:
> If I want the other characters to work I need to change the code page:
>
> O:\>chcp 65001
> Active code page: 65001
>
> O:\>Q:\tools\Python33\python -c "import sys;
> sys.stdout.buffer.write('\u03b1\n'.encode('utf-8'))"
> α
>
> O:\>Q:\tools\
On Thu, Nov 8, 2012 at 12:54 PM, wrote:
> Font has nothing to do here.
> You are "simply" wrongly encoding your "unicode".
>
'\u2013'
> '–'
'\u2013'.encode('utf-8')
> b'\xe2\x80\x93'
'\u2013'.encode('utf-8').decode('cp1252')
> '–'
No, it seriously is the font. This is what I ge
On Thu, Nov 8, 2012 at 1:54 PM, Prasad, Ramit wrote:
> Why would font not matter? Unicode is the abstract definition
> of all characters right? From that we map the abstract
> character to a code page/set, which gives real values for an
> abstract character. From that code page we then visually di
On Thu, Nov 8, 2012 at 4:33 PM, Steven D'Aprano
wrote:
> On Thu, 08 Nov 2012 20:34:58 +0300, Andriy Kornatskyy wrote:
>
>> People who come from strongly typed languages that offer interfaces
>> often are confused by lack of one in Python. Python, being dynamic
>> typing programming language, follo
On Fri, Nov 9, 2012 at 12:20 AM, Graham Fielding wrote:
> file_object = open('savegame.sav', 'wb')
Here you open a file and assign it to "file_object".
> file['map'] = map
Here you attempt to write to "file" instead of "file_object". "file"
is the name of a built-in type, hence your e
On Fri, Nov 9, 2012 at 4:37 AM, Steven D'Aprano
wrote:
> In Python 3.3:
>
> py> class X(int):
> ... def __init__(self, *args):
> ... super().__init__(*args) # does nothing, call it anyway
> ...
> py> x = X(22)
> Traceback (most recent call last):
> File "", line 1, in
> File "",
On Fri, Nov 9, 2012 at 2:18 AM, Helmut Jarausch
wrote:
> Hi,
>
> probably I'm missing something.
>
> Using str(Arg) works just fine if Arg is a list.
> But
> str([],encoding='latin-1')
>
> gives the error
> TypeError: coercing to str: need bytes, bytearray or buffer-like object,
>
On Fri, Nov 9, 2012 at 10:17 AM, danielk wrote:
> I'm converting an application to Python 3. The app works fine on Python 2.
>
> Simply put, this simple one-liner:
>
> print(chr(254))
>
> errors out with:
>
> Traceback (most recent call last):
> File "D:\home\python\tst.py", line 1, in
> pr
On Fri, Nov 9, 2012 at 2:46 PM, danielk wrote:
> D:\home\python>pytest.py
> Traceback (most recent call last):
> File "D:\home\python\pytest.py", line 1, in
> print(chr(253).decode('latin1'))
> AttributeError: 'str' object has no attribute 'decode'
>
> Do I need to import something?
Ramit
On Sat, Nov 10, 2012 at 3:58 PM, Roy Smith wrote:
> I'm trying to pull down tweets with one of the many twitter APIs. The
> particular one I'm using (python-twitter), has a call:
>
> data = api.GetSearch(term="foo", page=page)
>
> The way it works, you start with page=1. It returns a list of twe
On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico wrote:
> I would not assume that. The origin is a point, just like any other.
> With a Line class, you could deem a zero-length line to be like a
> zero-element list, but Point(0,0) is more like the tuple (0,0) which
> is definitely True.
It's more
On Sat, Nov 10, 2012 at 7:53 PM, Roy Smith wrote:
> In article ,
> Ian Kelly wrote:
>
>> On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico wrote:
>> > I would not assume that. The origin is a point, just like any other.
>> > With a Line class, you could dee
On Sat, Nov 10, 2012 at 11:43 PM, Ian Kelly wrote:
> Where I wrote "(0,0) is the origin" above I was not referring to a
> point, not a tuple, but I can see how that was confusing.
What I meant to say is I *was* referring to a point. Gah!
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, Nov 11, 2012 at 3:24 PM, Cantabile wrote:
> I'd like to do something like that instead of the 'for' loop in __init__:
>
> assert[key for key in required if key in params.keys()]
A list evaluates as true if it is not empty. As long as at least one
of the required parameters is present, th
On Fri, Nov 9, 2012 at 6:36 AM, Steven D'Aprano
wrote:
> (I think... I really don't actually know if Zooey Deschanel can sing or
> not. Just go along with the example.)
Not only does she sing, she's in a band.
http://en.wikipedia.org/wiki/She_%26_Him
I take your point about the "looks like" ter
On Mon, Nov 12, 2012 at 6:00 PM, Cleuson Alves wrote:
> Hello, I need to solve an exercise follows, first calculate the inverse
> matrix and then multiply the first matrix.
> I await help.
> Thank you.
> follows the code below incomplete.
So what is the specific problem with the code that you're
On Mon, Nov 12, 2012 at 8:08 PM, Mark Lawrence wrote:
> http://stackoverflow.com/questions/tagged/python
>
> "Python has two major versions (2 and 3) in use which have significant
> differences."
>
> I believe that this is incorrect. The warts have been removed, but
> significant differences, not
On Tue, Nov 13, 2012 at 3:31 AM, andrea crotti
wrote:
> but it's a bit ugly. I wonder if I can use the subprocess PIPEs to do
> the same thing, is it going to be as fast and work in the same way??
It'll look something like this:
>>> p1 = subprocess.Popen(cmd1, shell=True, stdout=subprocess.PIPE
On Tue, Nov 13, 2012 at 9:07 AM, Ian Kelly wrote:
> It'll look something like this:
>
>>>> p1 = subprocess.Popen(cmd1, shell=True, stdout=subprocess.PIPE,
>>>> stderr=subprocess.PIPE)
>>>> p2 = subprocess.Popen(cmd2, shell=True, stdin=
On Tue, Nov 13, 2012 at 9:25 AM, Ian Kelly wrote:
> Sorry, the example I gave above is wrong. If you're calling
> p1.communicate(), then you need to first remove the p1.stdout pipe
> from the Popen object. Otherwise, the communicate() call will try to
> read data from it and
On Tue, Nov 13, 2012 at 11:05 PM, Kushal Kumaran
wrote:
> Or, you could just change the p1's stderr to an io.BytesIO instance.
> Then call p2.communicate *first*.
This doesn't seem to work.
>>> b = io.BytesIO()
>>> p = subprocess.Popen(["ls", "-l"], stdout=b)
Traceback (most recent call last):
On Thu, Nov 15, 2012 at 12:33 PM, Andriy Kornatskyy
wrote:
>
> A lazy attribute is an attribute that is calculated on demand and only once.
>
> The post below shows how you can use lazy attribute in your Python class:
>
> http://mindref.blogspot.com/2012/11/python-lazy-attribute.html
>
> Comments
On Thu, Nov 15, 2012 at 12:33 PM, Andriy Kornatskyy
wrote:
>
> A lazy attribute is an attribute that is calculated on demand and only once.
>
> The post below shows how you can use lazy attribute in your Python class:
>
> http://mindref.blogspot.com/2012/11/python-lazy-attribute.html
>
> Comments
On Fri, Nov 16, 2012 at 12:28 AM, wrote:
> Can someone explain the below behavior please?
>
re1 = re.compile(r'(?:((?:1000|1010|1020))[ ]*?[\,]?[ ]*?){1,3}')
re.findall(re_obj,'1000,1020,1000')
> ['1000']
re.findall(re_obj,'1000,1020, 1000')
> ['1020', '1000']
Try removing the gro
On Fri, Nov 16, 2012 at 2:44 PM, wrote:
> Latin1 has a block of 32 undefined characters.
These characters are not undefined. 0x80-0x9f are the C1 control
codes in Latin-1, much as 0x00-0x1f are the C0 control codes, and
their Unicode mappings are well defined.
http://tools.ietf.org/html/rfc134
On Fri, Nov 16, 2012 at 4:27 PM, wrote:
> They are indeed undefined: ftp://std.dkuug.dk/JTC1/sc2/wg3/docs/n411.pdf
>
> """ The shaded positions in the code table correspond
> to bit combinations that do not represent graphic
> characters. Their use is outside the scope of
> ISO/IEC 88
On Fri, Nov 16, 2012 at 5:33 PM, Nobody wrote:
> If you need to support either, you can parse it as ISO-8859-1 then
> explicitly convert C1 codes to their Windows-1252 equivalents as a
> post-processing step, e.g. using the .translate() method.
Or just create a custom codec by taking the one in
L
On Fri, Nov 16, 2012 at 6:30 PM, Steven D'Aprano
wrote:
> Does anyone use StandardError in their own code? In Python 2, I normally
> inherit from StandardError rather than Exception. Should I stop and just
> inherit from Exception in both 2 and 3?
According to the docs, StandardError is for built
On Sat, Nov 17, 2012 at 11:08 AM, Ian Kelly wrote:
> On Sat, Nov 17, 2012 at 9:56 AM, wrote:
>> "should" is a wish. The reality is that documents (and especially URLs)
>> exist that can be decoded with latin1, but will backtrace with cp1252. I see
>&
On Sat, Nov 17, 2012 at 9:56 AM, wrote:
> "should" is a wish. The reality is that documents (and especially URLs) exist
> that can be decoded with latin1, but will backtrace with cp1252. I see this
> as a sign that a small refactorization of cp1252 is in order. The proposal is
> to change thos
On Sun, Nov 18, 2012 at 7:42 PM, Mark Lawrence wrote:
> To throw a chiseldriver into the works, IIRC a tuple is way faster to create
> but accessing a list is much faster. The obvious snag is that may have been
> Python 2.7 whereas 3.3 is completely different. Sorry but I'm currently
> wearing m
On Mon, Nov 19, 2012 at 7:30 AM, Roy Smith wrote:
> In article <50a9e5cf$0$21863$c3e8da3$76491...@news.astraweb.com>,
> Steven D'Aprano wrote:
>>
>> By the way, based on the sample data you show, your script is possibly
>> broken. You don't record either the line number that raises, or the
>> ex
On Mon, Nov 19, 2012 at 4:15 PM, Dennis Lee Bieber
wrote:
> On Sun, 18 Nov 2012 17:52:35 -0800 (PST), su29090 <129k...@gmail.com>
> declaimed the following in gmane.comp.python.general:
>
>>
>> I all of the other problems but I have issues with these:
>>
>> 1.Given a positive integer n , assign T
On Sun, Nov 18, 2012 at 10:30 PM, Pavel Solin wrote:
> I would like to introduce a new Python textbook
> aimed at high school students:
>
> http://femhub.com/textbook-python/.
>
> The textbook is open source and its public Git
> repository is located at Github:
>
> g...@github.com:femhub/nclab-tex
On Tue, Nov 20, 2012 at 1:02 AM, Pavel Solin wrote:
> There is an ongoing discussion but we are not sure.
> Are there any reasons except for the print () command
> and division of integers?
The big one is that Python 3 holds the future of Python development.
There are no more feature releases pla
On Tue, Nov 20, 2012 at 10:29 AM, Marco wrote:
> Because when I call an instance the __call__ method is called, and because
> the classes are instances of type, I thought when I call a Foo class this
> imply the call type.__call__(Foo), and so this one manages the Foo.__new__
> and Foo.__init__ ca
On Tue, Nov 20, 2012 at 12:09 PM, Kevin T wrote:
> #if re.search( "rsrvd", sigName ) : #version a
> #if re.search( "rsrvd", sigName ) == None : #version b
> if re.search( "rsrvd", sigName ) is None : #version bb
>print sigName
>newVal = "%s%s" % ('1'*signal['bits'] , newVal )
> #else
On Tue, Nov 20, 2012 at 12:37 PM, Ian Kelly wrote:
> On Tue, Nov 20, 2012 at 12:09 PM, Kevin T wrote:
>> #if re.search( "rsrvd", sigName ) : #version a
>> #if re.search( "rsrvd", sigName ) == None : #version b
>> if re.search( "rsrvd", si
On Tue, Nov 20, 2012 at 7:58 AM, Daniel Klein wrote:
> If you try to expand any of the paths in the Path Browser (by clicking the +
> sign) then it not only closes the Path Browser but it also closes all other
> windows that were opened in IDLE, including the IDLE interpreter itself.
>
> I did a G
On Tue, Nov 20, 2012 at 2:49 PM, Daniel Klein wrote:
> With the assistance of this group I am understanding unicode encoding issues
> much better; especially when handling special characters that are outside of
> the ASCII range. I've got my application working perfectly now :-)
>
> However, I am
On Wed, Nov 21, 2012 at 3:58 PM, Dave Angel wrote:
> Some don't realize that one very powerful use for the .format style of
> working is that it makes localization much more straightforward. With
> the curly brace approach, one can translate the format string into
> another language, and if the p
On Wed, Nov 21, 2012 at 4:21 PM, Joshua Landau
wrote:
> "{}".format() is a blessing an "" % () should go. "%" has no relevance to
> strings, is hard to "get" and has an appalling* syntax. Having two syntaxes
> just makes things less obvious, and the right choice rarer.
>
> str.format is also reall
On Thu, Nov 22, 2012 at 5:24 AM, Colin J. Williams wrote:
> From my reading of the docs, it seems to me that the three following should
> be equivalent:
>
> (a) formattingStr.format(values)
> with
> (b) format(values, formattingStr)
> or
> (c) tupleOfValues.__format__(formattingStr
>
> Examp
On Fri, Nov 23, 2012 at 9:57 AM, Peng Yu wrote:
> Hi,
>
> The empty() returns True even after put() has been called. Why it is
> empty when there some items in it? Could anybody help me understand
> it? Thanks!
>
> ~/linux/test/python/man/library/multiprocessing/Queue/empty$ cat
> main.py
> #!/usr
On Fri, Nov 23, 2012 at 11:46 AM, Roy Smith wrote:
> My command either takes two positional arguments (in which case, both
> are required):
>
> $ command foo bar
>
> or the name of a config file (in which case, the positional arguments
> are forbidden):
>
> $ command --config file
>
> How can I re
On Sat, Nov 24, 2012 at 4:14 AM, Alasdair McAndrew wrote:
> I can resize a 2d image "im" with a command something like:
>
> r,c = shape(im)
> im2 = resize(im,(r//2,c//2))
>
> However, resize doesn't seem to work with an RGB image:
>
> r,c,n = shape(im) # returns, say 500 600 3
>
> I then need to
On Mon, Nov 26, 2012 at 9:56 AM, Nobody wrote:
> In a dynamically-typed language such as Python, the set of acceptable
> types for an argument is determined by the operations which the function
> performs on it. This is in direct contrast to a statically-typed language,
> where the set of acceptab
On Mon, Nov 26, 2012 at 2:58 PM, Dave Angel wrote:
> Not how I would put it. In a statically typed language, the valid types
> are directly implied by the function parameter declarations,
As alluded to in my previous post, not all statically typed languages
require parameter type declarations to
On Wed, Nov 28, 2012 at 12:39 PM, Kevin T wrote:
> with other languages i always expand tabs to spaces. the vi plugin does
do this properly. if i change all indents to be spaces only will python
behave? i inherited a good deal of the code that i am using, which is tab
based.
Yes, it's best to
On Wed, Nov 28, 2012 at 2:34 PM, Ricky wrote:
>
> Hi all,
>
> I am doing a project on traffic simulation. I want to introduce
> exponential arrival distribution to precede this task. Therefore I want
> write a code in python for exponential arrival distribution. I am very new
> for programming an
On Wed, Nov 28, 2012 at 5:20 PM, Dennis Lee Bieber wrote:
> On 28 Nov 2012 21:39:03 GMT, Steven D'Aprano
> declaimed the following in
> gmane.comp.python.general:> py> if True:
> > ... if True: # tab
> > ... pass # tab, then four spaces
> > ... pass # two spaces, tab, four s
On Thu, Nov 29, 2012 at 9:07 AM, lars van gemerden wrote:
> > PS: this is somewhat simpler than the actual case i've encountered, and
> i haven't tested this exact case, but for now i hope this is enough to get
> some of your insight.
>
> I know for sure that the imports both import the same file,
On Mon, Dec 3, 2012 at 10:37 AM, wrote:
> if found_0 == True or found_1 == True:
>
Not related to your problem, but this line would be more pythonic as:
if found_0 or found_1:
My puzzle two-fold. First: how could that code generate an "index our of
> range" error, and second: lin
On Mon, Dec 3, 2012 at 3:17 PM, Peng Yu wrote:
> Hi,
>
> I'm not able to find the documentation on what locale is used for
> sorted() when the 'cmp' argument is not specified. Could anybody let
> me what the default is? If I always want LC_ALL=C, do I need to
> explicitly set the locale? Or it is
On Tue, Dec 4, 2012 at 11:48 AM, Alexander Blinne wrote:
> Am 04.12.2012 19:28, schrieb DJC:
> (i for i,v in enumerate(w) if v.upper() != v).next()
> > Traceback (most recent call last):
> > File "", line 1, in
> > AttributeError: 'generator' object has no attribute 'next'
>
> Yeah, i saw
On Tue, Dec 4, 2012 at 12:04 PM, wrote:
> Dear Group,
>
> I am trying to use the cluster module as,
> >>> from cluster import *
> >>> data = [12,34,23,32,46,96,13]
> >>> cl = HierarchicalClustering(data, lambda x,y: abs(x-y))
> >>> cl.getlevel(10)
> [[96], [46], [12, 13, 23, 34, 32]]
> >>> cl.get
401 - 500 of 3558 matches
Mail list logo