On Thu, Dec 1, 2011 at 2:15 PM, Roy Smith wrote:
> for suffix in [''] + [str(i) for i in xrange(-1, -20, -1)]:
>
> It generates the right sequence of strings. But, if you came upon that
> code, would it make sense to you, or would you spend half the afternoon
> trying to figure out what it did an
On 1 December 2011 03:15, Roy Smith wrote:
> I need to try a bunch of names in sequence until I find one that works
> (definition of "works" is unimportant). The algorithm is:
>
> 1) Given a base name, "foo", first see if just plain "foo" works.
>
> 2) If not, try "foo-1", "foo-2", and so on
>
>
Hi,
I would like to read from a pipe, parse the input and ask the user
what to do next:
message = sys.stdin.read()
# message is parsed and URLs are printed as a list to choose from...
selected_index = raw_input('Which URL to open?')
Calling raw_input() always raises in an EOFError. I tried reope
Hi,
up to now I use this code to parse date values from emails:
msg=email.message_from_file(open(file_name))
date=None
date_str=msg.get('date')
if date_str:
date_tuple=email.utils.parsedate_tz(date_str)
if date_tuple:
date=datetime.datetime.fromtimestamp(email.utils.mktime_tz(date
Chris Rebert writes:
> C does not have a built-in fixed-point datatype, so the `struct`
> module doesn't handle fixed-point numbers directly.
The built-in decimal module supports fixed-point arithmetic, but the
struct module doesn't know about it. A bug report (or patch) by someone
who works wi
On 11/30/2011 01:32 PM, Neal Becker wrote:
> I like to hash a list of words (actually, the command line args of my
> program)
> in such a way that different words will create different hash, but not
> sensitive
> to the order of the words. Any ideas?
>
Do youmean hash like digest like md5sum
On 12/01/2011 11:01 AM, janedenone wrote:
Hi,
>
> I would like to read from a pipe, parse the input and ask the user
> what to do next:
>
> message = sys.stdin.read()
With above line you said, that you want to read ALL data from stdin, so
it's obvious that any following command will be unable
Hi there,
I'm a complete beginner to Python and, aside from HTML and CSS, to coding in
general. I've spent a few hours on it and think I understand most of the syntax.
However, I'm wondering a bit about For Loops. I know that the basic syntax for
them is to define a list, and then to use someth
for x in y
However, what does "for" and "in" mean in this context?
It means basically the same as in Englsish
Does the following links answer the question ?
http://www.ibiblio.org/g2swap/byteofpython/read/for-loop.html
http://dsnra.jpl.nasa.gov/software/Python/diveintopython.pdf (page 58)
H
On 01/12/2011 08:53, Mark wrote:
Hi there,
I'm a complete beginner to Python and, aside from HTML and CSS, to coding in
general. I've spent a few hours on it and think I understand most of the syntax.
However, I'm wondering a bit about For Loops. I know that the basic syntax for
them is to d
I find it easier to code like this
Sql = ‘’’select yadda, yadda, yadda
FROM a,b,c
Where this=that
ORDER BY deudderting’’’
With the appropriate %s(varname) and % against a dictionary rather than
positional args, but that’s just me.
From: python-list-bounces+frsells=adventistcare...
On 12/01/2011 06:32 AM, Pedro Henrique G. Souto wrote:
On 01/12/2011 08:53, Mark wrote:
Hi there,
I'm a complete beginner to Python and, aside from HTML and CSS, to
coding in general. I've spent a few hours on it and think I
understand most of the syntax.
However, I'm wondering a bit about
Thanks a lot for the answers everyone, I really appreciate you getting back to
me so quickly. I think that I understand where I am with this now :)
--
http://mail.python.org/mailman/listinfo/python-list
Mark writes:
> I'm a complete beginner to Python and, aside from HTML and CSS, to
> coding in general. I've spent a few hours on it and think I understand
> most of the syntax.
Welcome!
You should work your way through the Python tutorial, from beginning to
end http://docs.python.org/tutorial/>
Gelonida N wrote:
> On 11/30/2011 01:32 PM, Neal Becker wrote:
>> I like to hash a list of words (actually, the command line args of my
>> program) in such a way that different words will create different hash, but
>> not sensitive
>> to the order of the words. Any ideas?
>>
> Do youmean hash li
Steven D'Aprano wrote:
> On Thu, 01 Dec 2011 00:00:52 -0500, Roy Smith wrote:
>
> > Another possibility is setting your TERM environment variable to
> > something that readline can't support:
> >
> > ~$ TERM=asr33
> > ~$ python
> > Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) [GCC 4.2.1 (Ap
On Wednesday, November 30, 2011 8:47:13 PM UTC+8, Peter Otten wrote:
> Neal Becker wrote:
>
> > I like to hash a list of words (actually, the command line args of my
> > program) in such a way that different words will create different hash,
> > but not sensitive to the order of the words. Any id
On 12/01/2011 10:35 AM, 8 Dihedral wrote:
On Wednesday, November 30, 2011 8:47:13 PM UTC+8, Peter Otten wrote:
Neal Becker wrote:
I like to hash a list of words (actually, the command line args of my
program) in such a way that different words will create different hash,
but not sensitive
On Thursday, December 1, 2011 11:52:46 PM UTC+8, Dave Angel wrote:
> On 12/01/2011 10:35 AM, 8 Dihedral wrote:
> > On Wednesday, November 30, 2011 8:47:13 PM UTC+8, Peter Otten wrote:
> >> Neal Becker wrote:
> >>
> >>> I like to hash a list of words (actually, the command line args of my
> >>>
On Fri, Dec 2, 2011 at 2:52 AM, Dave Angel wrote:
> On 12/01/2011 10:35 AM, 8 Dihedral wrote:
>> I knew a hash can replace a bi-directional linked list.
>> The value can be a multi-field string to be parsed for further actions.
>> Is this what you are asking?
>
> A hash is a number, so I don
I'm new to python and I'm trying to get a twitter client running on a new
machine but it keeps on failing. I tracked the problem down to an issue opening
URLs and wrote this little test case:
import urllib2
url = 'http://www.google.com/'
opener = urllib2.build_opener()
url_data = opener.open(url
> Our servers have the same version of python and we're running the same
> OS (Fedora 14). Can anyone think of what might be causing this problem,
> or why it works on most (but not all) machines?
>
> Thanks
Is the server able to resolve www.google.com properly? If so, are you
POSITIVE that the
On Nov 29, 3:04 am, Steven D'Aprano wrote:
> On Tue, 29 Nov 2011 12:49:49 +1100, Chris Angelico wrote:
> > On Tue, Nov 29, 2011 at 11:54 AM, DevPlayer wrote:
> >> To me, I would think the interpreter finding the coder's intended
> >> indent wouldn't be that hard. And just make the need for consis
Adrian Powell wrote:
I'm new to python and I'm trying to get a twitter client running on a new
machine but it keeps on failing. I tracked the problem down to an issue opening
URLs and wrote this little test case:
import urllib2
url = 'http://www.google.com/'
opener = urllib2.build_opener()
url
to run the tests, I sit at my dev machine and SSH to the server where I can
copy & paste the test case directly into the python interpreter. If there's a
typo, it's going to both of them equally.
I am concerned about the name lookup since our servers have had some network
glitches in the past a
On Thu, 01 Dec 2011 13:43:38 -0500, Adrian Powell wrote:
> Since I'm actually trying to write a twitter client, I was more focused
> on the results from twitter. Since google and twitter are so huge and so
> distributed, I'd bet neither are good tests for this, but they look
> approximately right.
Announcing Urwid 1.0.1 and Urwid 0.9.9.3
Urwid home page:
http://excess.org/urwid/
Manual:
http://excess.org/urwid/wiki/UrwidManual
Tarballs:
http://excess.org/urwid/urwid-1.0.1.tar.gz
http://excess.org/urwid/urwid-0.9.9.3.tar.gz
About these rel
Arnaud Delobelle wrote:
> On 1 December 2011 03:15, Roy Smith wrote:
>> I need to try a bunch of names in sequence until I find one that works
>> (definition of "works" is unimportant). The algorithm is:
>>
>> 1) Given a base name, "foo", first see if just plain "foo" works.
>>
>> 2) If not, try
The curl & dig ideas were great, thanks. Turns out the machine's network was
badly configured and that's probably what was causing this problem. Curiously
firefox could browse these sites without any problem despite not having any
proxy defined and it took the command line to reveal the issue.
On 01/12/2011 03:15, Roy Smith wrote:
Well, I have seen much worse, so the WTFs/minute(*) count won't be too bad.
However, as general rule for readability; If you think you have to ask,
don't bother asking, spend that time rethinking and write a more
readable solution.
*) http://www.osnews
On Thu, 01 Dec 2011 21:13:51 +, Martin P. Hellwig wrote:
> On 01/12/2011 03:15, Roy Smith wrote:
> Well, I have seen much worse, so the WTFs/minute(*) count won't be too
> bad.
>
> However, as general rule for readability; If you think you have to ask,
> don't bother asking, spend that time
On 12/1/11 4:53 AM, Mark wrote:
Hi there,
I'm a complete beginner to Python and, aside from HTML and CSS, to coding in
general. I've spent a few hours on it and think I understand most of the syntax.
However, I'm wondering a bit about For Loops. I know that the basic syntax for
them is to def
On Thu, 01 Dec 2011 10:03:53 -0800, DevPlayer wrote:
[...]
> Well, that may be a little hyperbolic. But with 2 spaces you can
> encourage coders to get very deep, indentially, and still fit 80 chars.
Why would you want to encourage coders to write deeply indented code?
In my opinion, if your cod
On Fri, Dec 2, 2011 at 11:43 AM, Steven D'Aprano
wrote:
> Why would you want to encourage coders to write deeply indented code?
>
> In my opinion, if your code is indented four or more levels, you should
> start to think about refactorising your code; if you reach six levels,
> your code is probab
On Fri, Dec 2, 2011 at 11:15 AM, Steven D'Aprano
wrote:
> Try this on for size.
>
>
> f = type(q)(c[c.index(chr(45))+1:])+type(q)(1)
> c = str.join('\n', list(map(chr, (45, 48))) + [c])[::2]
> c = (lambda a,b: a+b)(c[:c.index(chr(45))+1], type(c)(f))
I wou
On 12/1/11, janedenone wrote:
> Hi,
>
> I would like to read from a pipe, parse the input and ask the user
> what to do next:
>
> message = sys.stdin.read()
> # message is parsed and URLs are printed as a list to choose from...
> selected_index = raw_input('Which URL to open?')
>
> Calling raw_inp
On 11/30/2011 10:49 PM, Matt Joiner wrote:
def possible_names():
yield "foo"
for i in range(20):
yield "foo-" + str(i)
This is my favorite -- crystal clear with only the variable part
variable. And it works in both 2.x and 3.x.
--
Terry Jan Reedy
--
http://mail.python.org
I have sub-classes of cmd.Cmd in an arrangement somewhat like
class Config(cmd.Cmd):
def do_foo(self, line): print "Fooing %r" % line
def complete_foo(self, text, line, begidx, endidx):
...
class MyTUI(cmd.Cmd):
def __init__(self, configger=Config, *args, **kwargs):
c
On Friday, December 2, 2011 12:18:29 AM UTC+8, Chris Angelico wrote:
> On Fri, Dec 2, 2011 at 2:52 AM, Dave Angel wrote:
> > On 12/01/2011 10:35 AM, 8 Dihedral wrote:
> >> I knew a hash can replace a bi-directional linked list.
> >> The value can be a multi-field string to be parsed for furt
On Fri, 02 Dec 2011 03:18:29 +1100, Chris Angelico wrote:
> On Fri, Dec 2, 2011 at 2:52 AM, Dave Angel wrote:
>> On 12/01/2011 10:35 AM, 8 Dihedral wrote:
>>> I knew a hash can replace a bi-directional linked list. The value can
>>> be a multi-field string to be parsed for further actions.
On Fri, Dec 2, 2011 at 3:29 PM, 8 Dihedral
wrote:
> I clear my point a hash is a collection of (key, value) pairs that have
> well defined methods and behavior to be used in programming.
>
> The basic operations of a hash normally includes the following:
>
> 1. insertion of a (key, value) pair
Thank you. ಠ_ಠ
On Fri, Dec 2, 2011 at 1:49 PM, Terry Reedy wrote:
> On 11/30/2011 10:49 PM, Matt Joiner wrote:
>>
>> def possible_names():
>> yield "foo"
>> for i in range(20):
>> yield "foo-" + str(i)
>
>
> This is my favorite -- crystal clear with only the variable part variable
On Fri, 02 Dec 2011 13:07:57 +1100, Chris Angelico wrote:
> On Fri, Dec 2, 2011 at 11:15 AM, Steven D'Aprano
> wrote:
>> Try this on for size.
>>
>>
>> f = type(q)(c[c.index(chr(45))+1:])+type(q)(1) c
>> = str.join('\n', list(map(chr, (45, 48))) +
>> [
On Friday, December 2, 2011 1:00:10 PM UTC+8, Chris Angelico wrote:
> On Fri, Dec 2, 2011 at 3:29 PM, 8 Dihedral
> wrote:
> > I clear my point a hash is a collection of (key, value) pairs that have
> > well defined methods and behavior to be used in programming.
> >
> > The basic operations of
On Fri, Dec 2, 2011 at 4:34 PM, Steven D'Aprano
wrote:
> On Fri, 02 Dec 2011 13:07:57 +1100, Chris Angelico wrote:
>> I would consider integer representations of ASCII to be code smell. It's
>> not instantly obvious that 45 means '-', even if you happen to know the
>> ASCII table by heart (which m
On 2/12/11 03:46:10, Dan Stromberg wrote:
You can read piped data from sys.stdin normally. Then if you want
something from the user, at least on most *ix's, you would open
/dev/tty and get user input from there. 'Not sure about OS/X.
Reading from /dev/tty works fine on OS/X.
-- HansM
--
ht
46 matches
Mail list logo