On 03/25/12 07:18, Alexander Blinne wrote:
I am not sure I understand your argument. The doc section states that
" [...] in Python you’re forced to write this:
while True:
line = f.readline()
if not line:
break
... # do something with line".
That simply isn't true as on
On 03/25/12 08:11, Chris Angelico wrote:
On Mon, Mar 26, 2012 at 12:03 AM, Tim Chase
wrote:
Granted, this can be turned into an iterator with a yield, making the issue
somewhat moot:
No, just moving the issue to the iterator. Your iterator has exactly
the same structure in it.
Yeah, it
On 03/25/12 10:16, Kiuhnm wrote:
On 3/25/2012 15:48, Tim Chase wrote:
The old curmudgeon in me likes the Pascal method of using "=" for
equality-testing, and ":=" for assignment which feels a little closer to
mathematical use of "=".
Unfortunately, ":=&qu
On 03/25/12 17:59, Dennis Lee Bieber wrote:
On Sun, 25 Mar 2012 08:48:31 -0500, Tim Chase
Yeah, it has the same structure internally, but I'm somewhat
surprised that the DB connection object doesn't have an
__iter__() that does something like this automatically under the
covers.
On 03/26/12 08:59, Thomas Rachel wrote:
Am 25.03.2012 15:03 schrieb Tim Chase:
while True:
data = conn.fetchmany()
if not data: break
for row in data:
process(row)
Or simpler
for data in iter(conn.fetchmany, []):
for row in data:
process(row)
Nice
On 03/27/12 10:32, Prasad, Ramit wrote:
fileread = open('myfile.txt','r')
tbook = eval(fileread.read())
fileread.close()
The use of eval is dangerous if you are not *completely* sure what is
being passed in. Try using pickle instead:
http://docs.python.org/release/2.5.2/lib/pickle-example.html
On 03/27/12 16:53, Anatoli Hristov wrote:
On Tue, Mar 27, 2012 at 5:53 PM, Tim Chase wrote:
On 03/27/12 10:32, Prasad, Ramit wrote:
fileread = open('myfile.txt','r')
tbook = eval(fileread.read())
fileread.close()
The use of eval is dangerous if you are not *completely
On 03/28/12 13:05, Ross Ridge wrote:
Ross Ridge wr=
But a Python Unicode string might be stored in several
ways; for all you know, it might actually be stored as a sequence of
apples in a refrigerator, just as long as they can be referenced
correctly.
But it is in fact only stored in one part
On 03/29/12 12:48, Nathan Rice wrote:
Of course, this describes Lisp to some degree, so I still need to
provide some answers. What is wrong with Lisp? I would say that the
base syntax being horrible is probably the biggest issue.
Do you mean something like:
((so (describes Lisp (to degree so
PHP is a language that I wish would die off quickly and
gracefully. I feel like the good things of PHP have already
been subsumed into the ecosystems of stronger programming
languages (including Python).
The one killer feature PHP has to offer over other languages:
ease of efficient deployment
On 04/04/12 17:34, Miki Tebeka wrote:
Greetings,
I'm going to give a "Python Gotcha's" talk at work.
If you have an interesting/common "Gotcha" (warts/dark corners ...) please
share.
(Note that I want over http://wiki.python.org/moin/PythonWarts already).
1) While I believe it was fixed in m
On 04/10/12 08:36, Kiuhnm wrote:
On 4/10/2012 14:29, Ulrich Eckhardt wrote:
Am 09.04.2012 20:57, schrieb Kiuhnm:
That won't do. A good example is when you pass a function to
re.sub, for instance.
If that's a good example, then why not use it? I've used it on
multiple occasions to do lookups
On 04/13/12 22:54, Chris Angelico wrote:
Yes, that would be the right method to use. I'd not bother with the
function and map() though, and simply iterate:
d = {}
for val in l:
d.setdefault(f(val), []).append(val)
Or make d a defaultdict:
from collections import defaultdict
d = defaultd
On 04/20/12 11:45, Kiuhnm wrote:
IOW, you can't define "->" or "=>", but you could define">=" or ">>".
You can also "overload" '<-' ;)
Oooh, that's evil. Slick, but evil! :-D
-tkc
--
http://mail.python.org/mailman/listinfo/python-list
On 04/21/12 14:44, Roy Smith wrote:
***
* *
* First Name and Last *
* ENGR 109-X *
* Fall 2999 *
* Format Example *
* *
***
You
On 04/24/12 18:18, Rotwang wrote:
Sorry if this is a stupid question, but what is up with this:
>>> from calendar import*
>>> Calendar
Traceback (most recent call last):
File "", line 1, in
Calendar
NameError: name 'Calendar' is not defined
>>> from calendar import Calendar
On 04/27/12 07:23, Chris Angelico wrote:
On Fri, Apr 27, 2012 at 10:17 PM, John O'Hagan wrote:
results = [x = expensive_call(i) for i in iterable if condition(x)]
Nest it:
results = [x for x in (expensive_call(i) for i in iterable) if condition(x)]
While it's what I do in cases like this,
On 05/02/12 19:52, Peng Yu wrote:
> The following example demonstrates the variable 'v' used in the
> list comprehension is accessible out site the list
> comprehension.
It did in Python 2.x but has been fixed in 3.x:
tim@bigbox:~$ python3
Python 3.1.3 (r313:86834, Nov 28 2010, 10:01:07)
[GCC 4.4
On 05/02/12 21:14, Steve Howell wrote:
> I'm looking for a fairly lightweight key/value store that works for
> this type of problem:
>
> ideally plays nice with the Python ecosystem
> the data set is static, and written infrequently enough that I
> definitely want *read* performance to trump a
On 05/03/12 19:36, Peng Yu wrote:
> list(a_set)
>
> When convert two sets with the same elements to two lists, are the
> lists always going to be the same (i.e., the elements in each list are
> ordered the same)? Is it documented anywhere?
Sets are defined as unordered which the documentation[1]
On 05/04/12 10:27, Steve Howell wrote:
> On May 3, 6:10 pm, Miki Tebeka wrote:
>>> I'm looking for a fairly lightweight key/value store that works for
>>> this type of problem:
>>
>> I'd start with a benchmark and try some of the things that are already in
>> the standard library:
>> - bsddb
>> -
On 05/04/12 12:22, Steve Howell wrote:
> Which variant do you recommend?
>
> """ anydbm is a generic interface to variants of the DBM database
> — dbhash (requires bsddb), gdbm, or dbm. If none of these modules
> is installed, the slow-but-simple implementation in module
> dumbdbm will be used.
>
On 05/04/12 14:14, Emile van Sebille wrote:
> On 5/4/2012 10:46 AM Tim Chase said...
>
> I hit a few snags testing this on my winxp w/python2.6.1 in that getsize
> wasn't finding the file as it was created in two parts with .dat and
> .dir extension.
Hrm...must be a
On 05/12/12 05:51, Chris Angelico wrote:
> On Sat, May 12, 2012 at 8:41 PM, John O'Hagan
> wrote:
>> Not sure if this is only package-manager specific, but
>> occasionally I come across a module that sounds interesting,
>> install it (in my case by apt-get), and then can't find it,
>> because the
On 05/12/12 03:30, Alec Taylor wrote:
> I am building a project requiring high performance and scalability,
> entailing:
Most of the frameworks are sufficiently scalable. Scalability
usually stems from design decisions (architecture and algorithm) and
caching, and you'll usually hit bandwidth or
On 05/13/12 16:36, Irmen de Jong wrote:
> Why do you care anyway? Pyc files are an implementation detail.
I could see wanting to pre-compile .pyc files for performance if
they'll then be stored on a read-only medium (a CD/DVD, a RO network
share, or a RO drive partition all come to mind).
You can
On 05/11/12 13:58, vacu wrote:
> I am frustrated to see %d not working in my Python 2.7 re.search, like
> this example:
>
(re.search('%d', "asdfdsf78asdfdf")).group(0)
> Traceback (most recent call last):
> File "", line 1, in
> AttributeError: 'NoneType' object has no attribute 'group'
>
On 05/13/12 16:14, Massi wrote:
> Hi everyone,
> I know this question has been asked thousands of times, but in my case
> I have an additional requirement to be satisfied. I need to handle
> substrings in the form 'string with spaces':'another string with
> spaces' as a single token; I mean, if I h
Sparring with a little sandbox/test code (in 2.6, FWIW), I'm trying
to set up some instance variables in my __init__ but keep hitting my
head against the wall.
Initially, I had something of the form
class MyServer(SocketServer.BaseRequestHandler):
def __init__(self, *args, **kwargs):
On 05/21/12 08:10, Steven D'Aprano wrote:
> On Mon, 21 May 2012 08:37:29 -0400, Roy Smith wrote:
>
> [...]
>> The above code works, but it occurs to me that I could use the much
>> shorter:
>>
>> def experience_text(self):
>> return dict(CHOICES).get("self.level", "???")
>>
>> So, the
On 05/24/12 09:32, Phil Le Bienheureux wrote:
>> I would like to pass something like this into a function
>> test(val1,val2,'>=')
>
> You can pass an operator as an argument to your function.
>
> See :
> http://docs.python.org/library/operator.html
And if you want to use strings, you can map them
On 06/01/12 15:05, Ethan Furman wrote:
> MRAB wrote:
>> I'd probably think of a record as being more like a dict (or an
>> OrderedDict)
>> with the fields accessed by key:
>>
>> record["name"]
>>
>> but:
>>
>> record.deleted
>
> Record fields are accessible both by key and by attribute --
On 06/01/12 19:05, Jon Clements wrote:
> On 01/06/12 23:13, Tim Chase wrote:
>>dbf.scatter_fields
>>
>> *always* trump and refer to the method.
>
> I did think about *trumping* one way or the other, but both *ugh*.
For the record, it sounded like the OP wante
On 06/02/12 00:16, Ethan Furman wrote:
> Tim Chase wrote:
>> On 06/01/12 19:05, Jon Clements wrote:
>>> On 01/06/12 23:13, Tim Chase wrote:
>>>>dbf.scatter_fields
>>>>
>>>> *always* trump and refer to the method.
>>> I did think a
On 06/13/12 17:44, Gilles wrote:
> On 13 Jun 2012 22:16:51 GMT, Steven D'Aprano
> wrote:
>> Surely the obvious answer is that a framework offers the benefit that you
>> don't have to write the application from scratch.
>
> Yes, but between receiving the query and sending the response, what
> fea
On 06/03/2011 09:42 AM, Cathy James wrote:
I need a jolt here with my python excercise, please somebody!! How can I
make my functions work correctly? I tried below but I get the following
error:
if f_dict[capitalize]:
KeyError:
def capitalize (s):
Here you define the variable "capitalize" as
On 06/09/2011 01:22 AM, Eric Snow wrote:
Sometimes when using class inheritance, I want the overriding methods
of the subclass to get the docstring of the matching method in the
base class. You can do this with decorators (after the class
definition), with class decorators, and with metaclasses
On 06/10/2011 05:30 AM, Francesc Segura wrote:
Hello all, I'm new to this and I'm having problems on summing two
values at python.
I get the following error:
Traceback (most recent call last):
File "C:\edge-bc (2).py", line 168, in
if (costGG<= cost + T0):
TypeError: unsupported operand
On 06/10/2011 12:58 PM, Mark Phillips wrote:
How do I write my script so it picks up argument from the
output of commands that pipe input into my script?
You can check
if os.isatty(sys.stdin): # <-- this check
do_stuff_with_the_terminal()
else:
read_options_from_stdin()
-tkc
-
On 06/10/2011 04:00 PM, Benjamin Kaplan wrote:
On Fri, Jun 10, 2011 at 11:31 AM, Tim Chase
if os.isatty(sys.stdin): #<-- this check
Any reason for that over sys.stdin.isatty()?
my knowledge of os.isatty() existing and my previous lack of
knowledge about sys.stdin.isatty()
:)
-
On 06/11/2011 08:32 PM, Andrew Berg wrote:
I'm pretty happy that I can copy variables and their value from one
object's namespace to another object's namespace with the same variable
names automatically:
b.__dict__.update(a.__dict__)
The reason I'm posting this is to ask what to watch out for w
On 06/13/2011 04:55 PM, Tycho Andersen wrote:
On Mon, Jun 13, 2011 at 11:31:29PM +0200, Tracubik wrote:
4print "this is a very long string that i'm going to
write 5 here, it'll be for sure longer than 80 columns"
Is there a better way to split the string?
There is! Python (as C) c
On 06/13/2011 05:38 PM, Chris Angelico wrote:
On Tue, Jun 14, 2011 at 8:33 AM, Tim Chase
wrote:
print ("this is not "
"such a huge line "
"even though it has "
"lots of text in it."
)
print (
"this is not "
"
On 06/15/2011 07:33 AM, Daniel Rentz wrote:
Am 15.06.2011 14:29, schrieb Olivier LEMAIRE:
Hi there, I've been looking for 2 days for a way to convert integer
to binary number 0-padded, nothing... I need to get numbers converted
with a defined number of bits. For example on 8 bits 2 = 0010
On 06/18/2011 05:55 AM, bruno.desthuilli...@gmail.com wrote:
On 18 juin, 06:17, John Salerno wrote:
class Character:
base_health = 50
base_resource = 10
def __init__(self, name):
self.name = name
self.health = base_health
self.resource = base_resource
On 06/18/2011 06:21 PM, Cathy James wrote:
freq = [] #empty dict to accumulate words and word length
While you say you create an empty dict, using "[]" creates an
empty *list*, not a dict. Either your comment is wrong or your
code is wrong. :) Given your usage, I presume you want a di
On 06/19/2011 08:41 PM, Steven D'Aprano wrote:
The last couple of messages on this list show up
fine on the mailman archives, but are empty posts on comp.lang.python. Is
there a problem with the mail -> usenet gateway?
I haven't noticed any issues. I tend to send via email
(python-list@pyth
On 06/20/2011 05:19 PM, Ben Finney wrote:
“This method of string formatting is the new standard in
Python 3.0, and should be preferred to the % formatting
described in String Formatting Operations in new code.”
http://docs.python.org/library/stdtypes.html#str.format>
Is there a good link to a
On 06/20/2011 09:17 PM, Terry Reedy wrote:
On 6/20/2011 8:46 PM, Tim Chase wrote:
On 06/20/2011 05:19 PM, Ben Finney wrote:
“This method of string formatting is the new standard in
Python 3.0, and should be preferred to the % formatting
described in String Formatting Operations in new code
On 06/21/2011 05:19 PM, Terry Reedy wrote:
On 6/21/2011 7:33 AM, Tim Chase wrote:
http://docs.python.org/library/stdtypes.html#str.format>
Is there a good link to a thread-archive on when/why/how .format(...)
became "preferred to the % formatting"?
That is a controversial sta
On 06/30/2011 11:29 PM, Steven D'Aprano wrote:
The dir() function is designed for interactive use, inspecting objects for
the names of attributes and methods.
Here is an enhanced version that allows you to pass a glob to filter the
names you see:
Comments and improvements welcome.
Having not
On 07/02/2011 01:08 PM, John Salerno wrote:
On Jul 2, 12:33 pm, MRAB wrote:
roll_die = move(roll_die)
You should be defining a function (a callable) and then passing it to a
decorator which returns a callable.
But why does the documentation say "The return value of the decorator
need n
On 07/02/2011 06:46 PM, rantingrick wrote:
On Jul 2, 6:38 pm, Chris Angelico wrote:
It saddens me when i see API's that don't include at least three
language choices. No *one* language is going to please the masses.
C or C++ bindings will cover most languages.
This is pretty much the entire
On 07/05/2011 05:35 PM, rantingrick wrote:
One thing is for sure, i always get a giggle from your self
defeating posts. You're the best enemy a person could have.
Thank you. *bows*
Every time I see a rantingrick post, it's like watching the Black
Knight scene from the Holy Grail yet again. Yo
On 07/06/2011 02:49 AM, Rama Rao Polneni wrote:
After storing 1.99 GB data in to the dictionary, python stopped to
store the remaining data in to dictionary.
Is there any alternate solution to resolve this issue. Like splitting
the dictionaries or writing the data to hard disk instead of writing
On 07/06/2011 11:24 AM, Chris Angelico wrote:
On Thu, Jul 7, 2011 at 1:10 AM, rantingrick wrote:
Wow nice corner case. Can you come up with at least five of them
though? You and I both know that the vast majority of GUI's require
visible windows.
Five corner cases. Okay. One is xkill; if I ca
On 07/08/2011 02:45 AM, Tim Roberts wrote:
yorick wrote:
I'm trying to access a hardware board of my company through a serial
connection using a Python script and the pyserial module.
The board to which I'm trying to connect works correctly with serial
as some other guys did some TCL scripts t
On 07/10/2011 05:50 PM, Tim Johnson wrote:
* pyt...@bdurham.com [110710 14:17]:
def test():
"""This is my doc string"""
print test.__doc__
test()
Works for me. Works for the application I'm after. thanks
Here's a related question:
## Is it possible to get the module docstrin
On 07/13/2011 06:26 AM, Thorsten Kampe wrote:
Source code is (unlike normal text) not read line by line. So
you (at least I) don't have to backtrack from line 2 to line 1
because you see them both at the same time.
$a
You mean there are people who don't use "ed" to write their code? ;-)
-tkc
.
On 07/16/2011 11:51 AM, rantingrick wrote:
1) Using only one indention token removes any chance of user error.
I'm not sure it "removes any chance of user error"...programmers
are an awfully error-prone lot -- especially beginners. Picking
one or the other might help reduce friction when lea
On 07/16/2011 10:10 PM, Steven D'Aprano wrote:
But I've never come across an email client that messes with
attachments. Just send your code as an attached .py file and
it's all good.
However I'm on a couple mailing lists (e.g. lurking on OpenBSD)
that strip all attachments...
-tkc
--
http
4) Tabs remove the need for complicated
indention/detention tools.
On 07/17/2011 10:15 AM, rantingrick wrote:
On Jul 17, 2:32 am, Ian Kelly wrote:
This. I used to think that tabs were better, for pretty
much the reasons Rick outlined, but I've had enough
problems with editors munging my tabs
On 07/17/2011 08:01 PM, Steven D'Aprano wrote:
Roy Smith wrote:
We don't have that problem any more. It truly boggles my
mind that we're still churning out people with 80 column
minds. I'm willing to entertain arguments about readability
of long lines, but the idea that there's something magic
On 07/19/2011 04:36 AM, J wrote:
Someone in a different forum suggested that I use 'binary
search' to iterate through the dictionaries
I'm not sure what they were smoking...a binary search is useful
for finding a thing in a sorted list. It looks like your data is
not sorted (strike #1) and i
On 07/19/2011 09:12 PM, sturlamolden wrote:
How I would prefer the GUI library to be, if based on "native"
widgets:
http://xkcd.com/927/
:-)
-tkc
--
http://mail.python.org/mailman/listinfo/python-list
On 07/20/2011 08:17 PM, rantingrick wrote:
RE: *Ben Finney changes thread subject*
Please everyone, do not change the subject of someone's thread because
it's considered rude. Thank you.
Right...do not change the subject because it's considered rude.
Change it because the topic drifted from
On 07/22/2011 03:26 AM, Lars Gustäbel wrote:
On Thu, Jul 21, 2011 at 08:46:05PM -0700, rantingrick wrote:
Tarfile is missing the attribute "fp" and instead exposes a
boolean "closed". This mismatching API is asinine! Both
tarfile and zipfile should behave EXACTLY like file objects
What do you
On 07/25/2011 11:45 AM, SigmundV wrote:
On Jul 24, 8:43 am, Laszlo Nagy wrote:
Can it be a problem on my side? I have tried from several different
computers. I cannot even ping it.
Whenever a page can't be accessed, although your connection is good,
http://www.downforeveryoneorjustme.com/ is
On 08/02/2011 04:32 AM, loial wrote:
I am trying to hardlink all files in a directory structure using
os.link.
Or is there an easier way to hardlink everything in a directory
structure?.
The requirement is for hard links, not symbolic links
While Peter & Thomas gave good answers, also be aware
On 08/03/2011 03:25 AM, Steven D'Aprano wrote:
gc wrote:
Target lists using comma separation are great, but they don't work
very well for this task. What I want is something like
a,b,c,d,e = *dict()
a, b, c, d, e = [dict() for i in range(5)]
Unfortunately there is no way of doing so withou
On 08/03/2011 03:36 AM, Katriel Cohn-Gordon wrote:
On Wed, Aug 3, 2011 at 9:25 AM, Steven D'Aprano wrote:
a, b, c, d, e = [dict() for i in range(5)]
I think this is good code -- if you want five different dicts,
then you should call dict five times. Otherwise Python will
magically call your ex
On 08/04/2011 07:43 AM, Billy Mays wrote:
Hey c.l.p.,
I wrote a little python script that finds the file that a python module
came from. Does anyone see anything wrong with this script?
#!/usr/bin/python
import sys
if __name__ == '__main__':
if len(sys.argv)> 1:
try:
On 08/04/2011 07:34 PM, Steven D'Aprano wrote:
Billy Mays wrote:
#!/usr/bin/python
I believe the recommended, platform independent hash-bang line is
#!/usr/bin/which python
I think you mean
#!/usr/bin/env python
-tkc
--
http://mail.python.org/mailman/listinfo/python-list
On 08/06/2011 02:49 AM, Chris Rebert wrote:
On Fri, Aug 5, 2011 at 10:49 PM, Devraj wrote:
My question, how do I chain decorators that end up executing the
calling method, but ensure that it's only called once.
That's how it works normally; decorators stack (and order is therefore
important).
On 08/09/2011 07:11 PM, Terry Reedy wrote:
On 8/9/2011 5:43 PM, Gelonida N wrote:
Now I wondered whether there is any way to implement a class such, that
I can write
for val in MyClass:
print val
And what are the items in a class that you expect that to produce?
I can see doing som
On 08/10/2011 05:42 PM, Chris Angelico wrote:
PS. I mistakenly sent this to a Gilbert& Sullivan group
first. Oddly enough, opera-goers are not used to discussing
the relative merits of braces vs indentation in code.
It's only fair turnabout:
http://coding.derkeiler.com/Archive/Python/comp.lan
On 08/12/2011 05:50 PM, Chris Angelico wrote:
You can write Perl code in the shape of a camel. Can you do that in Python?
Okay. Open challenge to anyone. Write a Python script that outputs
"Just another Python hacker" or some such message, and is shaped in
some way appropriately. And no fair doi
On 08/14/2011 12:38 PM, Chris Angelico wrote:
On Sun, Aug 14, 2011 at 6:21 PM, rantingrick wrote:
WRONG: "We are supposed to write clean code but i am not used to that"
RIGHT: "We are required to write clean code however i am not accustom
to that way of thinking.
Since when are we required t
On 08/14/2011 11:28 PM, Seebs wrote:
I tend to write stuff like
foo.array_of_things.sort.map { block }.join(", ")
I like this a lot more than
array = foo.array_of_things
sorted_array = array.sort()
mapped_array = [block(x) for x in sorted_array]
", ".join
On 08/16/2011 04:15 AM, smith jack wrote:
what is the advantage of Django over RoR:)
*THE* advantage is that you get to program in Python instead of
Ruby. :)
-tkc
--
http://mail.python.org/mailman/listinfo/python-list
On 08/16/2011 10:31 AM, Philip Semanchuk wrote:
On Aug 16, 2011, at 11:12 AM, Chris Angelico wrote:
There are several types of shadowing:
1) Deliberate shadowing because you want to change the behavior of the
name. Extremely rare.
2) Shadowing simply by using the name of an unusual builtin (lik
On 08/16/2011 12:11 PM, Seebs wrote:
Under which circumstance will you have more problems?
1. There is not a single shadowed built-in in the entire project.
2. There are dozens of shadowed built-ins based on when the original
programmer felt there wasn't going to be a need for a given built-in
On 08/16/2011 07:33 PM, John Gordon wrote:
I stand by my assertion that the phrase "I used to do X" carries the
meaning that you have done X in the past but DO NOT INTEND to do so
in the future.
I'd tweak the meaning to be something like "I did X regularly in
the past and I no longer do it reg
On 08/18/2011 07:22 AM, Mark Niemczyk wrote:
Or, using list comprehension.
numbers = [1, 2, 3, 4, 5]
numbers = [n + 5 for n in numbers]
numbers
[6, 7, 8, 9, 10]
Or, if you want it in-place:
numbers[:] = [n+5 for n in numbers]
which makes a difference if you have another reference to numb
On 08/23/2011 11:15 PM, Larry Hastings wrote:
Episode 1 has just been released!
You can find it at http://www.radiofreepython.com/ as of this very minute.
No Podcast/RSS feed...seriously? Downloaded manually and will
listen later, but best left to podcatchers :)
-tkc
--
http://mail.pytho
On 08/31/11 18:31, Gregory Ewing wrote:
The Python process should also be able to set its own
limits using resource.setrlimit().
A new corner of stdlib that I've never poked at. Thanks for the
suggestion. Disappointed though that it doesn't seem to have
docstrings on the functions, so I had
On 09/07/11 18:22, Laurent wrote:
Anyway I was just asking if there is something better than
enumerate. So the answer is no? The fact that I have to create
a tuple with an incrementing integer for something as simple
as checking that I'm at the head just sounds awfully
unpythonic to me.
I've ma
On 02/24/2011 04:46 PM, Verde Denim wrote:
On Thu, Feb 24, 2011 at 12:49 PM, MRAB wrote:
On 24/02/2011 16:41, Verde Denim wrote:
x = '0D'
y = '0x' + x
print "%d" % int(y,0)
TypeError: 'int' object is not callable
what am i not seeing here??
I can only assume that at some point you assign
On 03/11/2011 04:24 AM, GrayShark wrote:
Oh yes, Cobol also worked on VMS (yikes! the columns just
right issues!).
IDENTIFICATION DIVISION.
PROGRAM-ID. PAIN-PAIN-PAIN.
PROCEDURE DIVISION.
DISPLAY 'Thanks for dredging up painful memories'.
DISPLAY 'I've spen
On 03/11/2011 09:59 AM, Νικόλαος Κούρας wrote:
**
agent = os.environ['HTTP_USER_AGENT']
# determination of user browser
agent = agent.lower()
if 'chrome' in agent:
agent = 'Chrome'
if 'firefox' in agent:
agent = 'Firefox'
if 'opera' in agent:
agent = 'Oper
On 03/11/2011 12:21 PM, noydb wrote:
I am just looking to see if there is perhaps a more efficient way of
doing this below (works -- creates two random teams from a list of
players). Just want to see what the experts come up with for means of
learning how to do things better.
###
import random
On 03/25/2011 04:40 PM, Daniel Mahoney wrote:
On Fri, 25 Mar 2011 17:03:55 -0400, Ken D'Ambrosio wrote:
Hey, all. A co-worker asked me a question, and I've got no idea how (or
if) it can be done. Bottom line: he'd like to save off the text from an
interpreter session, his thinking being that
On 03/29/2011 08:14 PM, monkeys paw wrote:
How do i delete a module namespace once it has been imported?
I use
import banner
Then i make a modification to banner.py. When i import it again,
the new changes are not reflected. Is there a global variable i can
modify?
Delete it from sys.modules
On 03/31/2011 07:43 PM, candide wrote:
Suppose you have a string, for instance
"pyyythhooonnn ---> "
and you search for the subquences composed of the same character, here
you get :
'yyy', 'hh', 'ooo', 'nnn', '---', ''
>>> import re
>>> s = "pyyythhooonnn ---> "
>>> [m.group(0)
On 03/31/2011 07:43 PM, candide wrote:
"pyyythhooonnn ---> "
and you search for the subquences composed of the same character, here
you get :
'yyy', 'hh', 'ooo', 'nnn', '---', ''
Or, if you want to do it with itertools instead of the "re" module:
>>> s = "pyyythhooonnn ---> "
>>
On 04/11/2011 05:44 PM, Chris Angelico wrote:
On Tue, Apr 12, 2011 at 8:41 AM, MRAB wrote:
I'm not sure that "setdefault" should take **kw args for this because
of its existing argument structure (key + optional value).
A new method like "updatedefault" may be better, IMHO. It would act
like "
On 04/16/2011 02:17 AM, Ben Finney wrote:
Emacs can run Python in a buffer, and has “tabbar-mode” to
display a row of tabs
Likely the same features are available in Vim, by I've never
used Vim for lots of Python coding.
Vim since v7 has offered tabs, though I personally stick mostly
to split-
On 04/17/2011 04:19 PM, Ben Finney wrote:
No, it's not. Vim is THE way.
Clearly there is only one standard text editor, and that's ‘ed’
While it's funny, I'm curious how many folks on c.l.p have done
any/much python coding in ed. I've had to do a bit on a router
running an embedded Linux t
On 04/23/2011 11:51 AM, Dotan Cohen wrote:
harrismh777 wrote:
If an operation like (+) is used to add 1 + '1' then the
string should be converted to int and the addition should
take place, returning a reference to object int (2).
No, the int 1 should be cast to a string, and the result
shoul
On 04/26/2011 01:42 PM, Algis Kabaila wrote:
Thomas, have you tried bzr (Bazaar) and if so do you consider hg
(Mercurial) better?
And why is it better? (bzr is widely used in ubuntu, which is
my favourite distro at present).
Each of the main 3 (bzr, hg, git) have advantages and
disadvantage
201 - 300 of 2407 matches
Mail list logo