Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-29 Thread rusi
On Jun 10, 3:36 pm, Arnaud Delobelle  wrote:
> On 10 June 2012 07:16, rusi  wrote:
>
> > This is worth a read in this 
> > context:http://osteele.com/archives/2004/11/ides
>
> Interesting! I definitely fall nicely at one extreme of this
> dichotomy.  Every time I've tried to use an IDE, it's made me feel
> inadequate and I've quickly retreated to my comfort zone (emacs +
> xterm).

Here is a more recent discussion in the same vein:
http://henrikwarne.com/2012/06/17/programmer-productivity-emacs-versus-intellij-idea/

Reddited here:
http://www.reddit.com/r/programming/comments/vqb9l/programmer_productivity_emacs_versus_intellij_idea/

> I felt inadequate because I felt like the IDE was hindering
> me rather than helping me.  All I ask from the program that I use to
> write code is:
>
> * syntax highlighting
> * sensible auto-indenting
> * as little reliance on the mouse as possible
> * emacs key bindings :)

To some extent the new article just confirms the old Osteele one: viz.
Programmers stuck with java had better spend their time using the most
powerful tools to compensate for their inadequate language.

However it also indicates the opposite:
Benefits of sophisticated refactoring support are almost certainly
underestimated by users of vi/emacs.

>
> This article makes me feel more positive about my inability to feel
> comfortable in an IDE.  Thanks for the link!
>
> --
> Arnaud

T
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I can't send images to this mail-list

2012-06-29 Thread Dan Sommers
On Fri, 29 Jun 2012 21:59:41 -0400
Dave Angel  wrote:

> On 06/29/2012 06:59 PM, Dennis Lee Bieber wrote:
> > On Fri, 29 Jun 2012 21:13:09 +0100, Mark Lawrence
> >  declaimed the following in
> > gmane.comp.python.general:
> >
> >> On 29/06/2012 16:26, Ethan Furman wrote:
> >>> Ben Finney wrote:
>  Chris Angelico writes:
> > ??? wrote:
> >> why can't I send images to python-list@python.org??
> >>>  >>
> > It's a text-only list.
>  I'll take this opportunity to give heartfelt thanks to the
>  administrators for that policy; please keep this a text-only
>  forum.
> >>> +1000
> >>>
> >> I also entirely agree with this policy, but I've told you a
> >> trillion times not to exaggerate :)
> >>
> > +Googol
> +Googolplex
> or even
> 
> +Googolplexian

At the risk of skipping G1:

+Graham's Number?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-06-29 Thread Terry Reedy

On 6/29/2012 4:43 PM, Alister wrote:


from x import * is frowned upon, however, from x import y is fine IMHO.



well I said I was no expert & picking things up. re investigation I see
your reasoning and yes it was the from X import * I was thinking of.

Although a simple import X retaining the name-space ref does make it easy
to identify the origins of a function (at the expense of more typing)


import tkinter as tk
for example, to minimize extra typing while identifying source.
___
Terry Jan Reedy



--
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-06-29 Thread Terry Reedy

On 6/29/2012 4:49 PM, Littlefield, Tyler wrote:

I am no expert but from what have picked up so far from x import is
frowned upon in most cases


from x import *
# frowned on by many as reader will not necessarily know what that 
imports, conflicts are possible, and if you import * twice, reader may 
really not know what came from where


from x import y,x  # fine, common, used in stdlib
import x as y  # ditto
from x import y as z  # ditto
--
Terry Jan Reedy



--
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-06-29 Thread Steven D'Aprano
On Fri, 29 Jun 2012 19:41:11 +, Alister wrote:

> also this section in main strikes me as a bit odd and convoluted
> 
> w = world()
> serv = server(client)
> w.server = serv
> serv.world = w
> 
> I think you are cross referencing classes & would be better to
> investigate inheritance.

What you show above is composition, and is a perfectly valid technique, 
and in fact should often be *preferred* to inheritance.

The only slightly dubious part, and I stress *slightly*, is that there is 
a circular reference: w refers to serv, and serv refers back to w. While 
legitimate, it is a very slight "code smell" that should be investigated. 
If there is a way to get the same result without the circular reference, 
that would be preferred.

For example, perhaps server methods that need to know the world could 
take it as an explicit argument, rather than fetching it implicitly from 
server.world.

Or, a moderately advanced technique, use a weak-ref instead.

Inheritance should only be used to model "is-a" relationships. For 
example, Herbie the Love Bug is a Volkswagen Beetle, so inheritance is 
appropriate.

http://en.wikipedia.org/wiki/Herbie


class Vehicle(object):
pass

class Car(Vehicle):
pass

class Beetle(Car):
pass

herbie = Beetle()

Composition should be used to model "has-a" relationships. For example, a 
car has an engine, it is not a kind of engine, and so inheritance is 
inappropriate and composition should be used. I would re-write the Car 
class as follows:

class Engine(object):
pass

class Car(Vehicle):
def __init__(self):
self.engine = Engine()

So now we can talk about Herbie's engine:

herbie.engine  # Herbie, being a car, has an engine, he is not an engine



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re Following syntax error in Mac OX10.7 Terminal

2012-06-29 Thread Andrew Berg
On 6/29/2012 10:58 AM, David Thomas wrote:
> Just discovered this in the tutorial further down.  I'm currently learning 
> Python 2 because there seems to be a lot of tutorials out there covering 
> Python 2 rather than 3.
The latest edition (3rd?) of Programming Python by Mark Lutz covers py3k
(it targets 3.0/3.1 IIRC, but the official Python docs cover the
differences between versions). The tutorial in the official docs is
short compared to a book, but it covers the basics well. The official
docs do cover each module in the standard library in great detail. It is
mainly reference, though there are a few tutorials (e.g. the logging
module has at least 2 tutorials).

If you are not restricted to 2.x, learn 3.2/3.3. 2.x is used mainly
because some major libraries (e.g., Twisted, Django) and/or other
dependencies do not support 3.x yet. There will be no 2.8, and 2.7 isn't
getting any new features AFAIK.
-- 
CPython 3.3.0a4 | Windows NT 6.1.7601.17803
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I can't send images to this mail-list

2012-06-29 Thread Dave Angel
On 06/29/2012 06:59 PM, Dennis Lee Bieber wrote:
> On Fri, 29 Jun 2012 21:13:09 +0100, Mark Lawrence
>  declaimed the following in
> gmane.comp.python.general:
>
>> On 29/06/2012 16:26, Ethan Furman wrote:
>>> Ben Finney wrote:
 Chris Angelico writes:
> ??? wrote:
>> why can't I send images to python-list@python.org??
>>>  >>
> It's a text-only list.
 I'll take this opportunity to give heartfelt thanks to the
 administrators for that policy; please keep this a text-only forum.
>>> +1000
>>>
>> I also entirely agree with this policy, but I've told you a trillion 
>> times not to exaggerate :)
>>
> +Googol
+Googolplex
or even

+Googolplexian



-- 

DaveA

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-06-29 Thread Littlefield, Tyler
I am no expert but from what have picked up so far from x import is 
frowned upon in most cases also this section in main strikes me as a bit 
odd and convoluted w = world() serv = server(client) w.server = serv 
serv.world = w I think you are cross referencing classes & would be 
better to investigate inheritance.


From what I understand and how I've always employed it, inheritance is 
ment when you wish to give a class characteristics of another class. All 
I'm doing here is setting the world and server classes on each other, so 
they can call one another. This probably isn't needed in case of 
serv.server = w, but for sure the other way around.


--
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that 
dares not reason is a slave.

--
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-06-29 Thread Alister
On Fri, 29 Jun 2012 13:27:54 -0700, Martin P. Hellwig wrote:

> On Friday, 29 June 2012 20:41:11 UTC+1, Alister  wrote:
>> On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote:
>> 
>> > On 6/29/2012 1:31 AM, Steven D'Aprano wrote:
>> >> On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:
>> >>
>> >>> On Jun 29, 12:57 pm, "Littlefield, Tyler" 
>> >>> wrote:
>>  I was curious if someone wouldn't mind poking at some code. The
>>  project page is at:http://code.google.com/p/pymud Any information
>>  is greatly appreciated.
>> >>> I couldn't find any actual code at that site, the git repository is
>> >>> currently empty.
>> > 
>> > OOPS, sorry. Apparently I'm not as good with git as I thought.
>> > Everything's in the repo now.
>> 
>> I am no expert but from what have picked up so far
>> 
>> from x import
>> 
>>  is frowned upon in most cases
> 
> from x import * is frowned upon, however, from x import y is fine IMHO.
>> 
well I said I was no expert & picking things up. re investigation I see 
your reasoning and yes it was the from X import * I was thinking of.
 
Although a simple import X retaining the name-space ref does make it easy 
to identify the origins of a function (at the expense of more typing)
-- 
Flying is the second greatest feeling you can have.  The greatest feeling?
Landing...  Landing is the greatest feeling you can have.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-06-29 Thread Martin P. Hellwig
On Friday, 29 June 2012 20:41:11 UTC+1, Alister  wrote:
> On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote:
> 
> > On 6/29/2012 1:31 AM, Steven D'Aprano wrote:
> >> On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:
> >>
> >>> On Jun 29, 12:57 pm, "Littlefield, Tyler"  wrote:
>  I was curious if someone wouldn't mind poking at some code. The
>  project page is at:http://code.google.com/p/pymud Any information is
>  greatly appreciated.
> >>> I couldn't find any actual code at that site, the git repository is
> >>> currently empty.
> > 
> > OOPS, sorry. Apparently I'm not as good with git as I thought.
> > Everything's in the repo now.
> 
> I am no expert but from what have picked up so far
> 
> from x import 
> 
>  is frowned upon in most cases 

from x import * is frowned upon, however, from x import y is fine IMHO.
> 
> also this section in main strikes me as a bit odd and convoluted
> 
> w = world()
> serv = server(client)
> w.server = serv
> serv.world = w
> 
> I think you are cross referencing classes & would be better to 
> investigate inheritance.
> 

Generally speaking, read PEP8 and apply it please, there are tools like pylint 
that can help you with that. It also seems you are doing things quite java 
like, but I guess that is just a thing of getting used to python.

If you are planning to let your code being used like a framework that is 
extended by others, try to avoid more advanced functions just because they seem 
handy, always ask yourself is it clearer?

Try to unit-test your code and try to gain some decent code coverage, that will 
increase maturity of your code rather quickly.

But for the rest it looks like you are good in organizing it all in 
sub-modules, which is a very nice thing to see.

Good luck!

-- 
mph
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I can't send images to this mail-list

2012-06-29 Thread Mark Lawrence

On 29/06/2012 16:26, Ethan Furman wrote:

Ben Finney wrote:

Chris Angelico writes:

梦幻草 wrote:

why can't I send images to python-list@python.org??

 >>

It's a text-only list.


I'll take this opportunity to give heartfelt thanks to the
administrators for that policy; please keep this a text-only forum.


+1000



I also entirely agree with this policy, but I've told you a trillion 
times not to exaggerate :)


--
Cheers.

Mark Lawrence.



--
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-06-29 Thread MRAB

On 29/06/2012 20:41, Alister wrote:

On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote:


On 6/29/2012 1:31 AM, Steven D'Aprano wrote:

On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:


On Jun 29, 12:57 pm, "Littlefield, Tyler"  wrote:

I was curious if someone wouldn't mind poking at some code. The
project page is at:http://code.google.com/p/pymud Any information is
greatly appreciated.

I couldn't find any actual code at that site, the git repository is
currently empty.


OOPS, sorry. Apparently I'm not as good with git as I thought.
Everything's in the repo now.


I am no expert but from what have picked up so far

from x import

  is frowned upon in most cases


I think you mean:

from x import *


also this section in main strikes me as a bit odd and convoluted

 w = world()
 serv = server(client)
 w.server = serv
 serv.world = w

I think you are cross referencing classes & would be better to
investigate inheritance.





--
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-06-29 Thread Alister
On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote:

> On 6/29/2012 1:31 AM, Steven D'Aprano wrote:
>> On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:
>>
>>> On Jun 29, 12:57 pm, "Littlefield, Tyler"  wrote:
 I was curious if someone wouldn't mind poking at some code. The
 project page is at:http://code.google.com/p/pymud Any information is
 greatly appreciated.
>>> I couldn't find any actual code at that site, the git repository is
>>> currently empty.
> 
> OOPS, sorry. Apparently I'm not as good with git as I thought.
> Everything's in the repo now.

I am no expert but from what have picked up so far

from x import 

 is frowned upon in most cases 

also this section in main strikes me as a bit odd and convoluted

w = world()
serv = server(client)
w.server = serv
serv.world = w

I think you are cross referencing classes & would be better to 
investigate inheritance.


-- 
The bogosity meter just pegged.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 转发:Re:how can I implement "cd" like shell in Python?

2012-06-29 Thread Chris Withers

On 28/06/2012 12:39, 梦幻草 wrote:


thanks !But this method can not change the directory of the main
process.For example:
the current directory is "/home/work/local/scripts",this directory have
a python script file "cd.py"
after executing the script cd.py by "python cd.py ..",the current work
directory has no changes,the path is still "/home/work/local/scripts"


Sounds like you might want to give the ipython shell a go, since it has 
a lot of this already implemented.


cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: format() not behaving as expected

2012-06-29 Thread MRAB

On 29/06/2012 18:19, Josh English wrote:

On Friday, June 29, 2012 10:02:45 AM UTC-7, MRAB wrote:


The ".format" method accepts multiple arguments, so the placeholders in
the format string need to specify which argument to format as well as
how to format it (the format specification after the ":").

The "format" function, on the other hand, accepts only a single
argument to format, so it needs only the format specification, and
therefore can't accept subscripting or attributes.

 >>> c = "foo"
 >>> print "{0:s}".format(c)
foo
 >>> format(c, "s")
'foo'


Thank you. That's beginning to make sense to me. If I understand this,

> everything between the braces is the format specification,

and the format specification doesn't include the braces, right?


No, the format specification is the part after the ":" (if present), as
in the example.

Here are more examples:

>>> c = "foo"
>>> print "{0}".format(c)
foo
>>> format(c, "")
'foo'
>>> print "To 2 decimal places: {0:0.2f}".format(1.2345)
To 2 decimal places: 1.23
>>> print format(1.2345, "0.02f")
1.23
--
http://mail.python.org/mailman/listinfo/python-list


Re: format() not behaving as expected

2012-06-29 Thread Josh English
On Friday, June 29, 2012 10:08:20 AM UTC-7, Steven D'Aprano wrote:
>  c = (1,3)
>  s = "{0[0]}"
>  print s.format(c)
> > '1'
> 
> That's not actually the output copied and pasted. You have quotes around 
> the string, which you don't get if you pass it to the print command.
> 

Mea culpa. I typed it in manually because the direct copy and paste was rather 
ugly full of errors because of many haplographies.



>  print format(c,s)
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > ValueError: Invalid conversion specification
> [...]
> > Any idea why one form works and the other doesn't?
> 
> Because the format built-in function is not the same as the format string 
> method.
...
> 
> (Personally, I find the documentation about format to be less than 
> helpful.)
> 

Thanks. I think it's coming together.

Either way, this format seems uglier than what I had before, and it's longer to 
type out.  I suppose that's just programmers preference.

Josh

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: format() not behaving as expected

2012-06-29 Thread Josh English
On Friday, June 29, 2012 10:02:45 AM UTC-7, MRAB wrote:
> 
> The ".format" method accepts multiple arguments, so the placeholders in
> the format string need to specify which argument to format as well as
> how to format it (the format specification after the ":").
> 
> The "format" function, on the other hand, accepts only a single
> argument to format, so it needs only the format specification, and
> therefore can't accept subscripting or attributes.
> 
>  >>> c = "foo"
>  >>> print "{0:s}".format(c)
> foo
>  >>> format(c, "s")
> 'foo'

Thank you. That's beginning to make sense to me. If I understand this, 
everything between the braces is the format specification, and the format 
specification doesn't include the braces, right? 

Josh
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: format() not behaving as expected

2012-06-29 Thread Steven D'Aprano
On Fri, 29 Jun 2012 09:31:53 -0700, Josh English wrote:

> I have a list of tuples, and usually print them using:
> 
> print c, " ".join(map(str, list_of_tuples))
> 
> This is beginning to feel clunky (but gives me essentially what I want),
> and I thought there was a better, more concise, way to achieve this, so
> I explored the new string format and format() function:
> 
 c = (1,3)
 s = "{0[0]}"
 print s.format(c)
> '1'

That's not actually the output copied and pasted. You have quotes around 
the string, which you don't get if you pass it to the print command.


 print format(c,s)
> Traceback (most recent call last):
>   File "", line 1, in 
> ValueError: Invalid conversion specification
[...]
> Any idea why one form works and the other doesn't?

Because the format built-in function is not the same as the format string 
method.

The string method takes brace substitutions, like "{0[0]}" which returns 
the first item of the first argument.

The format function takes a format spec, not a brace substitution. For 
example:

>>> format(c, '<10s')
'(1, 3)'
>>> format(c, '>10s')
'(1, 3)'
>>> format(c, '*>10s')
'(1, 3)'

The details of the format spec are in the Fine Manual:

http://docs.python.org/library/string.html#formatspec

although sadly all the examples are about using brace substitutions, not 
format specs.

(Personally, I find the documentation about format to be less than 
helpful.)

You can also read the PEP that introduced the new formatting, but keep in 
mind that there have been some changes since the PEP was written, so it 
may not quite match the current status quo.

http://www.python.org/dev/peps/pep-3101/


-- 
Steven

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: format() not behaving as expected

2012-06-29 Thread MRAB

On 29/06/2012 17:31, Josh English wrote:

I have a list of tuples, and usually print them using:

print c, " ".join(map(str, list_of_tuples))

This is beginning to feel clunky (but gives me essentially what I want), and I 
thought there was a better, more concise, way to achieve this, so I explored 
the new string format and format() function:


c = (1,3)
s = "{0[0]}"
print s.format(c)

'1'

print format(c,s)

Traceback (most recent call last):
   File "", line 1, in 
ValueError: Invalid conversion specification

I'm running *** Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 
bit (Intel)] on win32. ***
(This is actually a PortablePython run on a Windows 7 machine)

Any idea why one form works and the other doesn't?


The ".format" method accepts multiple arguments, so the placeholders in
the format string need to specify which argument to format as well as
how to format it (the format specification after the ":").

The "format" function, on the other hand, accepts only a single
argument to format, so it needs only the format specification, and
therefore can't accept subscripting or attributes.

>>> c = "foo"
>>> print "{0:s}".format(c)
foo
>>> format(c, "s")
'foo'
--
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: psutil 0.5.0 released

2012-06-29 Thread Giampaolo Rodolà
2012/6/27 Giampaolo Rodolà :
> Hi folks,
> I'm pleased to announce the 0.5.0 release of psutil:
> http://code.google.com/p/psutil/
>
> === Major new features ===
>
> - system users
> - (Linux, Windows) process CPU affinity (get and set)
> - (POSIX) process number of opened file descriptors.
> - (Windows) process number of opened handles.
> - psutil.disk_partitions() now provides also mount options
> - new Process.as_dict() method.
> - Process.get_children(recursive=True): return all process descendants.
> - 2to3 is not longer required to run at installation time in order to
> support Python 3
> - ppid, name, exe, cmdline and create_time properties of Process class
> are now cached after being accessed.
> - psutil.process_iter() now caches Process instances between calls.
>
> For a complete list of features and bug fixes see:
> http://psutil.googlecode.com/svn/trunk/HISTORY
>
>
> === New features by example ===
>
 import psutil, os

 psutil.get_users()
> [user(name='giampaolo', terminal='pts/2', host='localhost',
> started=1340737536.0),
>  user(name='giampaolo', terminal='pts/3', host='localhost',
> started=1340737792.0)]

 psutil.disk_partitions()
> [partition(device='/dev/sda1', mountpoint='/', fstype='ext4', 
> opts='rw,nosuid'),
>  partition(device='/dev/sda2', mountpoint='/home', fstype='ext, opts='rw')]

 p = psutil.Process(os.getpid())
 p.get_num_fds()
> 4

 p.get_num_handles()  # windows only
> 254

 p.get_memory_maps()
> [mmap(path='/lib/x86_64-linux-gnu/libutil-2.15.so', rss=16384,
> anonymous=8192, swap=0),
>  mmap(path='/lib/x86_64-linux-gnu/libc-2.15.so', rss=6384,
> anonymous=15, swap=0),
>  mmap(path='/lib/x86_64-linux-gnu/libcrypto.so.1.0.0', rss=34124,
> anonymous=1245, swap=0),
>  mmap(path='[heap]', rss=54653, anonymous=8192, swap=0),
>  mmap(path='[stack]', rss=1542, anonymous=166, swap=0),
>  ...]

 p.as_dict()
> {'status': 0, 'pid': 29510, 'connections': [], 'cmdline': ['python'], ...}

 p.get_cpu_affinity()
> [0, 1, 2, 3]
 p.set_cpu_affinity([0])

 p.get_children(recursive=True)
> [, , ...]

>
>
> === Links ===
>
> * Home page: http://code.google.com/p/psutil
> * Source tarball: http://psutil.googlecode.com/files/psutil-0.5.0.tar.gz
> * Api Reference: http://code.google.com/p/psutil/wiki/Documentation
>
>
> Please try out this new release and let me know if you experience any
> problem by filing issues on the bug tracker.
> Thanks in advance.
>
>
> --- Giampaolo Rodola'
>
> http://code.google.com/p/pyftpdlib/
> http://code.google.com/p/psutil/
> http://code.google.com/p/pysendfile/

A last-moment bug on Windows appeared.
Please ignore 0.5.0 version and download 0.5.1:
http://psutil.googlecode.com/files/psutil-0.5.1.tar.gz


--- Giampaolo Rodola'

http://code.google.com/p/pyftpdlib/
http://code.google.com/p/psutil/
http://code.google.com/p/pysendfile/
-- 
http://mail.python.org/mailman/listinfo/python-list


format() not behaving as expected

2012-06-29 Thread Josh English
I have a list of tuples, and usually print them using:

print c, " ".join(map(str, list_of_tuples))

This is beginning to feel clunky (but gives me essentially what I want), and I 
thought there was a better, more concise, way to achieve this, so I explored 
the new string format and format() function:

>>> c = (1,3)
>>> s = "{0[0]}"
>>> print s.format(c)
'1'
>>> print format(c,s)
Traceback (most recent call last):
  File "", line 1, in 
ValueError: Invalid conversion specification

I'm running *** Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 
bit (Intel)] on win32. ***
(This is actually a PortablePython run on a Windows 7 machine)

Any idea why one form works and the other doesn't? 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re Re Following syntax error in Mac OX10.7 Terminal

2012-06-29 Thread Sergi Pasoev

> Just discovered this in the tutorial further down. I'm currently
> learning Python 2 because there seems to be a lot of tutorials out there
> covering Python 2 rather than 3.

While deciding which version of Python to learn, a better counsel could
be found here:

http://wiki.python.org/moin/Python2orPython3
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re Following syntax error in Mac OX10.7 Terminal

2012-06-29 Thread Ben Finney
David Thomas  writes:

> Hi yeah I'm currently learning python 2 at the moment and the tutorial
> that I am studying doesn't explain about indentation.

You might be better served by the official Python tutorial
http://docs.python.org/tutorial/>.

If you work through it from beginning to end, doing each exercise and
experimenting to be sure you understand before moving through, you will
get a good grounding in the fundamentals of the language.

-- 
 \   “Don't worry about what anybody else is going to do. The best |
  `\ way to predict the future is to invent it.” —Alan Kay |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re Following syntax error in Mac OX10.7 Terminal

2012-06-29 Thread David Thomas
On Friday, June 29, 2012 4:21:56 PM UTC+1, MRAB wrote:
> On 29/06/2012 16:13, David Thomas wrote:
> > On Thursday, June 28, 2012 6:30:42 PM UTC+1, Sergi Pasoev wrote:
> >> You just have to consider that indentation matters in Python, so you
> >> have to type the code in Python interpreter as you have written it
> >> below, that is, press Tab before each line when you are inside the
> >> 'while (or any other like for, if, with, etc.) block.
> >>
> >> a=0
> >> while a<10:
> >> a=a+1
> >> print a
> >>
> >> I can guess from your message that you aren't aware of one very
> >> important Python feature, and maybe you also didn't willingly choose to
> >> learn Python2 instead of Python3 ? In this case I would advise you to
> >> consider both versions before choosing.
> >
> > Hi yeah I'm currently learning python 2 at the moment and the tutorial that
> > I am studying doesn't explain about indentation.
> >
> Really? Indentation is a basic feature of Python!

while {condition that the loop continues}:
{what to do in the loop}
{have it indented, usually four spaces}
{the code here is not looped}
{because it isn't indented}

Just discovered this in the tutorial further down.  I'm currently learning 
Python 2 because there seems to be a lot of tutorials out there covering Python 
2 rather than 3.

Thanks for the help this community is great for help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re Following syntax error in Mac OX10.7 Terminal

2012-06-29 Thread MRAB

On 29/06/2012 16:13, David Thomas wrote:

On Thursday, June 28, 2012 6:30:42 PM UTC+1, Sergi Pasoev wrote:

You just have to consider that indentation matters in Python, so you
have to type the code in Python interpreter as you have written it
below, that is, press Tab before each line when you are inside the
'while (or any other like for, if, with, etc.) block.

a=0
while a<10:
a=a+1
print a

I can guess from your message that you aren't aware of one very
important Python feature, and maybe you also didn't willingly choose to
learn Python2 instead of Python3 ? In this case I would advise you to
consider both versions before choosing.


Hi yeah I'm currently learning python 2 at the moment and the tutorial that
I am studying doesn't explain about indentation.


Really? Indentation is a basic feature of Python!
--
http://mail.python.org/mailman/listinfo/python-list


Re: I can't send images to this mail-list

2012-06-29 Thread Ethan Furman

Ben Finney wrote:

Chris Angelico writes:

梦幻草 wrote:

why can't I send images to python-list@python.org??

>>

It's a text-only list.


I'll take this opportunity to give heartfelt thanks to the
administrators for that policy; please keep this a text-only forum.


+1000

--
http://mail.python.org/mailman/listinfo/python-list


Re: Re Following syntax error in Mac OX10.7 Terminal

2012-06-29 Thread David Thomas
On Thursday, June 28, 2012 6:30:42 PM UTC+1, Sergi Pasoev wrote:
> You just have to consider that indentation matters in Python, so you
> have to type the code in Python interpreter as you have written it
> below, that is, press Tab before each line when you are inside the
> 'while (or any other like for, if, with, etc.) block.
> 
> a=0
> while a<10:
> a=a+1
> print a 
> 
> I can guess from your message that you aren't aware of one very
> important Python feature, and maybe you also didn't willingly choose to
> learn Python2 instead of Python3 ? In this case I would advise you to
> consider both versions before choosing.

Hi yeah I'm currently learning python 2 at the moment and the tutorial that I 
am studying doesn't explain about indentation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-06-29 Thread Littlefield, Tyler


On 6/29/2012 1:31 AM, Steven D'Aprano wrote:

On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:


On Jun 29, 12:57 pm, "Littlefield, Tyler"  wrote:

I was curious if someone wouldn't mind poking at some code. The project
page is at:http://code.google.com/p/pymud Any information is greatly
appreciated.

I couldn't find any actual code at that site, the git repository is
currently empty.


OOPS, sorry. Apparently I'm not as good with git as I thought. 
Everything's in the repo now.


--
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-06-29 Thread Littlefield, Tyler

On 6/29/2012 2:14 AM, Serhiy Storchaka wrote:

The project page is at:
http://code.google.com/p/pymud
Any information is greatly appreciated.


Do you mean 
No, I mean http://code.google.com/p/pymud




--
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that 
dares not reason is a slave.

--
http://mail.python.org/mailman/listinfo/python-list


Re: I can't send images to this mail-list

2012-06-29 Thread Ben Finney
Chris Angelico  writes:

> On Thu, Jun 28, 2012 at 9:34 PM, 梦幻草  wrote:
> >     why can't I send images to python-list@python.org??
>
> It's a text-only list.

I'll take this opportunity to give heartfelt thanks to the
administrators for that policy; please keep this a text-only forum.

-- 
 \   “Come on Milhouse, there’s no such thing as a soul! It’s just |
  `\  something they made up to scare kids, like the Boogie Man or |
_o__)  Michael Jackson.” —Bart, _The Simpsons_ |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: retry many times decorator

2012-06-29 Thread Justin Barber
On Friday, June 29, 2012 4:53:43 AM UTC-4, andrea crotti wrote:
> On the other hand now that I think again even supposing there is a
> permanent error like MySql completely down, retrying continuosly
> won't do any harm anyway because the machine will not be able to do
> anything else anyway, when someone will fix MySql it would
> restart again without human intervention.
> 
> So I think I could even just let it retry and use maybe a SMTPHanlder
> for the logging errors, to make the notification of problems very
> quick..

Rather then write a decorator, sounds like you should write your own class or 
method connecting to the database that has the ability to retry. Are you 
finding you are decorating only db calls or are you decorating all sorts of 
stuff?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: retry many times decorator

2012-06-29 Thread andrea crotti
On the other hand now that I think again even supposing there is a
permanent error like MySql completely down, retrying continuosly
won't do any harm anyway because the machine will not be able to do
anything else anyway, when someone will fix MySql it would
restart again without human intervention.

So I think I could even just let it retry and use maybe a SMTPHanlder
for the logging errors, to make the notification of problems very
quick..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-06-29 Thread Serhiy Storchaka

The project page is at:
http://code.google.com/p/pymud
Any information is greatly appreciated.


Do you mean https://github.com/benthomasson/pymud, 
http://pymud.blogspot.com/ or http://sourceforge.net/projects/pymud/ ?


--
http://mail.python.org/mailman/listinfo/python-list


Re: I can't send images to this mail-list

2012-06-29 Thread Chris Angelico
On Thu, Jun 28, 2012 at 9:34 PM, 梦幻草  wrote:
> hi,all:
>     why can't I send images to python-list@python.org??
>

It's a text-only list. Post your image to some free hosting somewhere
and then include a link to it in your message, or - if possible -
explain your issue/question in text.

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-06-29 Thread Chris Angelico
On Fri, Jun 29, 2012 at 5:31 PM, Steven D'Aprano
 wrote:
> Given that all code contains bugs, that's the best sort of repository!

Only in the sense that a cheese shop can be lauded for its cleanliness...

But I am somewhat curious to see the OP's actual code. MUDs are my
personal specialty.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


I can't send images to this mail-list

2012-06-29 Thread ??????
hi,all:
why can't I send images to python-list@python.org??-- 
http://mail.python.org/mailman/listinfo/python-list


Re: code review

2012-06-29 Thread Steven D'Aprano
On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:

> On Jun 29, 12:57 pm, "Littlefield, Tyler"  wrote:
>> I was curious if someone wouldn't mind poking at some code. The project
>> page is at:http://code.google.com/p/pymud Any information is greatly
>> appreciated.
> 
> I couldn't find any actual code at that site, the git repository is
> currently empty.

Given that all code contains bugs, that's the best sort of repository!



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list