Regarding Jython support in IBM and HP platforms

2012-12-26 Thread Naresh Kumar



Hello,

I am trying to use the Jython in IBM AIX and HP machines to test our framework 
which is based on JAVA.
when trying to run our python and jython based testcases using system test 
framework we are getting below errors in jython.err file



Error: could not find libjava.so

Error: could not find Java 2 Runtime
Environment.” (Shared library of java)



Trying to find in online whether jython is supported on these two platforms HP 
and IBM and i could not able to get proper info.
so could you please provide me the info like what are all platforms it 
supports(jython)?
If not when do you guys are supporting on HP and IBM because java is pretty 
much support on all platforms and machine independent, so jython is similar 
like java.

Thanks in advance,
Naresh

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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-26 Thread Steven D'Aprano
On Tue, 25 Dec 2012 16:19:21 -0800, Rick Johnson wrote:

> On Tuesday, December 25, 2012 4:56:44 PM UTC-6, Steven D'Aprano wrote:
> 
>> Rick, what makes you think that this is logically inconsistent?
>> "Method" is the accepted name for functions attached to classes. They
>> report themselves as "methods":
>> [...]
>> There are two built-ins for creating different types of method: the
>> classmethod and staticmethod functions. If you don't think that these
>> objects should be called " method", then what do you think
>> that they should be called?
> 
> I'm  not arguing about against instance method/class method name
> convention, i am talking about instance variable/class variable; pay
> attention!

You compared the use of "instance/class method" and "instance/class 
variable", and complained that it was "logically inconsistent" to use one 
set of terms while objecting to the other. That could mean that you 
object to *both* terms, or that you prefer both terms. You didn't say 
which, so I covered both options.

Since you apparently don't object to "instance/class method", I can only 
assume that you think that "class variable" is a good term for something 
which is not necessarily a class.


>> On the other hand, the terms "instance variable" and "class variable"
>> are logically inconsistent with other terminology. It is common
>> practice, across dozens or hundreds of languages, to refer to variables
>> by their type
> 
> Variable have no "type", only the value of variable has a "type".

That is incorrect in general. In statically typed languages, variables do 
have types: the compiler keeps track that (e.g.) variable named "x" is a 
float, while variable named "s" is a string.

That does not apply to Python, of course, but under normal circumstances 
many variables have an implied type, or types. Only a very few variables 
are used with unrestricted values. If I write a function:

def spam(alist):
alist.sort()
alist += [None, 'x', 42]


then most people would understand that calling alist "a list variable" 
gives the intent that alist should hold a list (or something that quacks 
like a list) rather than a statement that the compiler will prevent you 
from passing a non-list to the function.


>> (either as declared, in static-typed languages like C or Haskell, or as
>> they are expected to hold a value in dynamic languages like Ruby and
>> Python):
>>
>> - an integer variable is a variable used to hold an integer; 
>> - a string variable is a variable used to hold a string;
>> - a float variable is a variable used to hold a float; 
>> - a boolean variable is be a variable used to hold a boolean; 
>> - for consistency, a class variable should be a variable used to
>>   hold a class, e.g.:
>>   classes = [bool, float, MyClass, Spam, Ham, AnotherClass] 
>>   for cls in classes:  # cls is a "class variable"
>>   print "The name of the class is", cls.__name__
>> - and similarly for consistency an instance variable should be a
>>   variable holding some arbitrary instance. Since everything in an
>>   instance in Python, this last one is too general to be useful.
> 
> Your "last one"(sic) comment negates your whole argument of referring to
> variables by what type the variable references. Since EVERYTHING is an
> obj then ALL variables should be termed "instance variables" (that's
> going by your logic of course).

Of course you could do so, but that would be pointless. Normally we refer 
to things by the most precise term to describe them, not the least 
precise. We might say:

"42 is an int, 23.0 is a float, and 'spam' is a string"

rather than:

"42 is an instance, 23.0 is an instance, and 'spam' is an instance".

Although the second sentence is equally correct, it is not equally 
useful. Rather like saying:

"Lassie is a dog, Bozo is a chimpanzee, and Robin Hood is a person"

versus:

"Lassie is a mammal, Bozo is a mammal, and Robin Hood is a mammal".


>> Unfortunately people coming to Python from certain other languages,
>> particularly Java, (mis)use "class variable" to mean something
>> completely different:
> 
> Don't try to confuse us with your illogical ways, Lord Steven. Your sad
> devotion to that ancient hatred of java has not helped you conjure up
> logical terminology, or given you enough clairvoyance to find the
> truth...

Thank you Admiral Motti.


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


need a url that its http response header that cotain 401 status code

2012-12-26 Thread iMath
I am going to do a  Basic Authentication ,
so I need a url 
 that its http response header that cotain 401 status code.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Command Line Progress Bar

2012-12-26 Thread peter

On 12/26/2012 03:17 AM, Kevin Anthony wrote:

Hello,
I'm writing a file processing script(Linux), and i would like to have 
a progress bar.  But i would also like to be able to print messages. 
 Is there a simple way of doing this without implementing something 
like ncurses?


--
Thanks
Kevin Anthony
www.NoSideRacing.com 

Do you use Banshee?
Download the Community Extensions:
http://banshee.fm/download/extensions/



I use this tecnique to make a progress bar in the console.
You just need to understand, that a progress bar is a 
cross-multiplication http://en.wikipedia.org/wiki/Cross-multiplication.


import sys, time

def progressbar(value, total):
maspro = (100*value) / total
sys.stdout.write('\r[%s]%d%%' % ('#'*(maspro/10), maspro))
sys.stdout.flush()

for a in range(1, 1000):
progressbar(a, 100)
time.sleep(2)


You can't combine your progress bar with threading module



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


Re: I am facing an issue while decoding json string using json.loads

2012-12-26 Thread alex23
On Dec 26, 5:14 pm, sajuptpm  wrote:
> I am facing an issue while decoding json string using json.loads(jstring).
> Its working, if i do json.dumps(eval(jstring)) before json.loads(jstring).

I cannot reproduce your problem using the original string:

>>> s = u'{"selected_objects":{"datacenter-2":{"name":"Data !@#$%25^&*()_ {}[]|%
5c%2f.,?><:\\"`Center8(Data !@#$%^&*()_ {}[]|/.,?><:\
\"`Center8)","type":"Da
tacenter","moid":"datacenter-2","ac tual_name":"Data !@#$%25^&*()_ {}
[]|%5c%2f.,
?><:\\"`Center8","server_pools":[{"name":"cluster ~!@#$%25^&*()_ {}|\
\":?><,.%2f
;\'%5c][=-`(cluster ~!@#$%^&*()_ {}|\\":?><,./;\'][=-
`)","type":"ClusterComp
uteResource","moid":"domain- c401","actual_name":"cluster ~!@#$
%25^&*()_ {}|\\":
?><,.%2f;\'%5c][=-`","hosts":[{"name":"192.168.1.13","type":"HostSys
tem","moid"
:"host-27","actual_name":"192.168.1.13"}]}]}}}'
>>> json.loads(s)
{u'selected_objects': {u'datacenter-2': {u'ac tual_name': u'Data !@#$
%25^&*()_ {
}[]|%5c%2f.,?><:"`Center8', u'moid': u'datacenter-2', u'type':
u'Datacenter', u'
name': u'Data !@#$%25^&*()_ {}[]|%5c%2f.,?><:"`Center8(Data !@#$
%^&*()_ {}[]|\\/
.,?><:"`Center8)', u'server_pools': [{u'hosts': [{u'actual_name':
u'192.168.1.13
', u'moid': u'host-27', u'type': u'HostSys tem', u'name':
u'192.168.1.13'}], u'a
ctual_name': u'cluster ~!@#$%25^&*()_ {}|":?><,.%2f;\'%5c][=-`',
u'moid': u'doma
in- c401', u'type': u'ClusterComputeResource', u'name': u'cluster ~!@#$
%25^&*()_
 {}|":?><,.%2f;\'%5c][=-`(cluster ~!@#$%^&*()_ {}|":?><,./;\'\\][=-
`)'}]}}}
>>>

Notice the space in the first occurance of the key 'actual_name' (and
later in 'HostSys tem') however. Could it be a non-printable character
like an EOL that's somehow managed to make its way into your string?

Other than that, I'm at a loss as to why you're seeing a difference.
Which version of Python are you using?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: need a url that its http response header that cotain 401 status code

2012-12-26 Thread Hans Mulder
On 26/12/12 10:08:41, iMath wrote:
> I am going to do a  Basic Authentication ,
> so I need a url 
>  that its http response header that cotain 401 status code.

Isn't that backwards?  I mean, what's the point of implementing
Basic Authentication, unless you already know a site that uses it?

if you don't know any such site, you can set one up easily:
just run a webserver on your laptop and password-protect a page
in your server configuration.

When you've found a suitable url, take a look at HTTPBasicAuthHandler
in the urllib2 modules.


Hope this helps,

-- HansM


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


Re: need a url that its http response header that cotain 401 status code

2012-12-26 Thread Chris Angelico
On Wed, Dec 26, 2012 at 8:08 PM, iMath  wrote:
> I am going to do a  Basic Authentication ,
> so I need a url
>  that its http response header that cotain 401 status code.

Looking into my binocular crystal ball, I see two things:

Left eye: You're trying to write a basic auth client, and want
something to test it on. See Hans's response.

Right eye: You want to write a basic auth server, and you need to know
how to return a 401.

Please provide 1.5 metric tons of additional information. What are you
trying to do, what libraries are you using, what's the failing code?

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


Re: EOFError why print(e) cannot print out any information ?

2012-12-26 Thread Peter Otten
iMath wrote:

> f = open('UsersInfo.bin','rb')
> while True:
> try:
> usrobj = pickle.load(f)
> except EOFError as e:
> print(e)
> break
> else:
> usrobj.dispuser()
> f.close()
 
> why print(e) cannot print out any information ?

Because the relevant code in pickle doesn't supply an error message; it's 
just

raise EOFError

While you can add the information yourself by subclassing the Unpickler...

class MyUnpickler(pickle.Unpickler):
def __init__(self, file, **kw):
super().__init__(file, **kw)
self.file = file
def load(self):
try:
return super().load()
except EOFError:
raise EOFError("EOFError: Reached end of {}".format(self.file))

with open('UsersInfo.bin','rb') as f:
load = MyUnpickler(f).load
while True:
try:
usrobj = load()
except EOFError as e:
print(e)
break
else:
usrobj.display()

... it might be a good idea to make a feature request on 
.

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


Twisted 12.3.0 released

2012-12-26 Thread Thomas Hervé
On behalf of Twisted Matrix Laboratories, I am pleased to announce, in
extremis, the release of Twisted 12.3.

161 tickets are closed by this release, with the following highlights:

 * Support for local parallel testing in trial

 * A new "react" function to easily run a single asynchronous function
in a script with the reactor.

 * Partial support for Python 3.3.

Note that only Python 2.7 is supported on Windows now. We also require
zope.interface 3.6.0 or newer.


For more information, see the NEWS file here:

 http://twistedmatrix.com/Releases/Twisted/12.3/NEWS.txt


Download it now from:

 http://pypi.python.org/packages/source/T/Twisted/Twisted-12.3.0.tar.bz2 or

 http://pypi.python.org/packages/2.7/T/Twisted/Twisted-12.3.0.win32-py2.7.msi


Thanks to the supporters of Twisted via the Software Freedom Conservancy
and to the many contributors for this release.

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


3.2 can't extract tarfile produced by 2.7

2012-12-26 Thread Antoon Pardon
I am converting some programs to python 3. These programs manipulate 
tarfiles. In order for the python3 programs to be really useful
they need to be able to process the tarfiles produced by python2 that 
however seems to be a problem.


This is testcode that produces a tarfile.

#! /usr/bin/python

compression = "bz2"
tarmode = "w|%s" % compression
rt = '.'

import os
import os.path
import errno

import tarfile as tar

def process():
pj = os.path.join
entries = os.listdir(rt)
of = open("DUMP.tbz", "w")
tf = tar.open(mode = tarmode, fileobj = of,
  encoding = 'ascii', format = tar.PAX_FORMAT)
for entry in entries:
fqpn = pj(rt, entry)
try:
tf.add(fqpn, entry, recursive = False)
except OSError as ErrInfo:
print("%s: disappeared" % fqpn)
if ErrInfo.errno != errno.ENOENT:
raise
tf.close()
of.close()

if __name__ == "__main__":
process()

==
This is testcode that checks a tarfile

#!/usr/bin/python

compression = "bz2"
tarmode = "r|%s" % compression

import os
import os.path
import stat

import tarfile as tar

def equalfile(fl1, fl2):
bf1 = fl1.read(8192)
bf2 = fl2.read(8192)
while bf1 == bf2:
if bf1 == "":
return True
bf1 = fl1.read(8192)
bf2 = fl2.read(8192)
return False

def process():
gf = open("DUMP.tbz", "r")
tf = tar.open(mode = tarmode, fileobj = gf,
  encoding = 'ascii', format = tar.PAX_FORMAT)
for tarinfo in tf:
entry = tarinfo.name
fileinfo = os.stat(entry)
if stat.S_ISREG(fileinfo.st_mode) and tarinfo.isreg():
bfl = tf.extractfile(tarinfo)
ofl = open(entry)
if not equalfile(bfl, ofl):
print("%s: does not match backup" % entry)
sync = False
tf.close()
gf.close()

if __name__ == "__main__":
process()

=

When I use python2.7 to produce and later check the tarfile everything 
works as expected. However when I use python3.2 to check the tarfile I

get the following traceback.

Traceback (most recent call last):
  File "tarchck", line 39, in 
process()
  File "tarchck", line 25, in process
encoding = 'ascii', format = tar.PAX_FORMAT)
  File "/usr/lib/python3.2/tarfile.py", line 1771, in open
t = cls(name, filemode, stream, **kwargs)
  File "/usr/lib/python3.2/tarfile.py", line 1667, in __init__
self.firstmember = self.next()
  File "/usr/lib/python3.2/tarfile.py", line 2418, in next
tarinfo = self.tarinfo.fromtarfile(self)
  File "/usr/lib/python3.2/tarfile.py", line 1281, in fromtarfile
buf = tarfile.fileobj.read(BLOCKSIZE)
  File "/usr/lib/python3.2/tarfile.py", line 573, in read
buf = self._read(size)
  File "/usr/lib/python3.2/tarfile.py", line 585, in _read
buf = self.__read(self.bufsize)
  File "/usr/lib/python3.2/tarfile.py", line 604, in __read
buf = self.fileobj.read(self.bufsize)
  File "/usr/lib/python3.2/codecs.py", line 300, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9e in position 10: 
invalid start byte


I have been looking around but have no idea how I have to adapt this 
code in order to have it process the tarfile under python3.2. The 
original code didn't have the coding and format keywords on the tar.open 
statement and after reading the documentation I thought that

would make things work, but no such luck. Further reading didn't
provide anything usefull

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


Re: Command Line Progress Bar

2012-12-26 Thread Irmen de Jong
On 26-12-2012 7:17, Kevin Anthony wrote:
> Hello, 
> I'm writing a file processing script(Linux), and i would like to have a 
> progress bar.
>  But i would also like to be able to print messages.  Is there a simple way 
> of doing
> this without implementing something like ncurses?

This little library can prove useful: http://pypi.python.org/pypi/fish/

-Irmen

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


Re: 3.2 can't extract tarfile produced by 2.7

2012-12-26 Thread Xavier Combelle

You probably want to write

of = open("DUMP.tbz", "wb")

and

gf =open("DUMP.tbz", "rb")
--
http://mail.python.org/mailman/listinfo/python-list


Re: Command Line Progress Bar

2012-12-26 Thread Alec Taylor
On Thu, Dec 27, 2012 at 3:05 AM, Irmen de Jong  wrote:
> On 26-12-2012 7:17, Kevin Anthony wrote:
>> Hello,
>> I'm writing a file processing script(Linux), and i would like to have a 
>> progress bar.
>>  But i would also like to be able to print messages.  Is there a simple way 
>> of doing
>> this without implementing something like ncurses?
>
> This little library can prove useful: http://pypi.python.org/pypi/fish/
>
> -Irmen
>
> --
> http://mail.python.org/mailman/listinfo/python-list

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


Re: 3.2 can't extract tarfile produced by 2.7

2012-12-26 Thread Benjamin Kaplan
On Dec 26, 2012 11:00 AM, "Antoon Pardon" 
wrote:
>
> I am converting some programs to python 3. These programs manipulate
tarfiles. In order for the python3 programs to be really useful
> they need to be able to process the tarfiles produced by python2 that
however seems to be a problem.
>
> This is testcode that produces a tarfile.
>
> #! /usr/bin/python
>
> compression = "bz2"
> tarmode = "w|%s" % compression
> rt = '.'
>
> import os
> import os.path
> import errno
>
> import tarfile as tar
>
> def process():
> pj = os.path.join
> entries = os.listdir(rt)
> of = open("DUMP.tbz", "w")
> tf = tar.open(mode = tarmode, fileobj = of,
>   encoding = 'ascii', format = tar.PAX_FORMAT)
> for entry in entries:
> fqpn = pj(rt, entry)
> try:
> tf.add(fqpn, entry, recursive = False)
> except OSError as ErrInfo:
> print("%s: disappeared" % fqpn)
> if ErrInfo.errno != errno.ENOENT:
> raise
> tf.close()
> of.close()
>
> if __name__ == "__main__":
> process()
>
>
==
> This is testcode that checks a tarfile
>
> #!/usr/bin/python
>
> compression = "bz2"
> tarmode = "r|%s" % compression
>
> import os
> import os.path
> import stat
>
> import tarfile as tar
>
> def equalfile(fl1, fl2):
> bf1 = fl1.read(8192)
> bf2 = fl2.read(8192)
> while bf1 == bf2:
> if bf1 == "":
> return True
> bf1 = fl1.read(8192)
> bf2 = fl2.read(8192)
> return False
>
> def process():
> gf = open("DUMP.tbz", "r")
> tf = tar.open(mode = tarmode, fileobj = gf,
>   encoding = 'ascii', format = tar.PAX_FORMAT)
> for tarinfo in tf:
> entry = tarinfo.name
> fileinfo = os.stat(entry)
> if stat.S_ISREG(fileinfo.st_mode) and tarinfo.isreg():
> bfl = tf.extractfile(tarinfo)
> ofl = open(entry)
> if not equalfile(bfl, ofl):
> print("%s: does not match backup" % entry)
> sync = False
> tf.close()
> gf.close()
>
> if __name__ == "__main__":
> process()
>
>
=
>
> When I use python2.7 to produce and later check the tarfile everything
works as expected. However when I use python3.2 to check the tarfile I
> get the following traceback.
>
> Traceback (most recent call last):
>   File "tarchck", line 39, in 
> process()
>   File "tarchck", line 25, in process
> encoding = 'ascii', format = tar.PAX_FORMAT)
>   File "/usr/lib/python3.2/tarfile.py", line 1771, in open
> t = cls(name, filemode, stream, **kwargs)
>   File "/usr/lib/python3.2/tarfile.py", line 1667, in __init__
> self.firstmember = self.next()
>   File "/usr/lib/python3.2/tarfile.py", line 2418, in next
> tarinfo = self.tarinfo.fromtarfile(self)
>   File "/usr/lib/python3.2/tarfile.py", line 1281, in fromtarfile
> buf = tarfile.fileobj.read(BLOCKSIZE)
>   File "/usr/lib/python3.2/tarfile.py", line 573, in read
> buf = self._read(size)
>   File "/usr/lib/python3.2/tarfile.py", line 585, in _read
> buf = self.__read(self.bufsize)
>   File "/usr/lib/python3.2/tarfile.py", line 604, in __read
> buf = self.fileobj.read(self.bufsize)
>   File "/usr/lib/python3.2/codecs.py", line 300, in decode
> (result, consumed) = self._buffer_decode(data, self.errors, final)
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9e in position 10:
invalid start byte
>
> I have been looking around but have no idea how I have to adapt this code
in order to have it process the tarfile under python3.2. The original code
didn't have the coding and format keywords on the tar.open statement and
after reading the documentation I thought that
> would make things work, but no such luck. Further reading didn't
> provide anything usefull
>
> --
> Antoon Pardon
> --

You're opening the file in text mode, so it's trying to decode it as text
using your default encoding (utf-8). You want the file read as a series of
bytes, so open it in binary mode.

gf =open("DUMP.tbz", "rb")
-- 
http://mail.python.org/mailman/listinfo/python-list


How to get time.strptime()?

2012-12-26 Thread Gnarlodious
Error: AttributeError: 'module' object has no attribute '_strptime'

This problem is driving me crazy. It only happens in Python 3.3.0, while on my 
server running 3.1.3 it behaves as expected. When I try to access 
time.strptime() it errors with

AttributeError: 'module' object has no attribute '_strptime'.

This error only occurs under mod_wsgi, when running as a one-shot webapp it 
behaves normally. All other functionalities of the time module are normal.

If anyone could explain why it thinks I want an underscored name maybe it would 
help. 

Thanks.

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


Re: How to get time.strptime()?

2012-12-26 Thread Chris Rebert
On Wednesday, December 26, 2012, Gnarlodious wrote:

> Error: AttributeError: 'module' object has no attribute '_strptime'
>

 Please include the full Traceback, not just the final error message.

This problem is driving me crazy. It only happens in Python 3.3.0, while on
> my server running 3.1.3 it behaves as expected. When I try to access
> time.strptime() it errors with
>
> AttributeError: 'module' object has no attribute '_strptime'.


Might be the wrong `time` module. What's `print time.__file__` output?
Did you perchance create a time.py file in your project?

This error only occurs under mod_wsgi, when running as a one-shot webapp it
> behaves normally. All other functionalities of the time module are normal.
>
> If anyone could explain why it thinks I want an underscored name maybe it
> would help.
>
> Thanks.
>
> -- Gnarlie
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
Cheers,
Chris
--
http://rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get time.strptime()?

2012-12-26 Thread Steven D'Aprano
On Wed, 26 Dec 2012 08:33:42 -0800, Gnarlodious wrote:

> Error: AttributeError: 'module' object has no attribute '_strptime'
> 
> This problem is driving me crazy. It only happens in Python 3.3.0, while
> on my server running 3.1.3 it behaves as expected. When I try to access
> time.strptime() it errors with
> 
> AttributeError: 'module' object has no attribute '_strptime'.
[...]
> If anyone could explain why it thinks I want an underscored name maybe
> it would help.

Perhaps if you were to read the ENTIRE traceback, not just the last line, 
you will see something that hints at an explanation. Here is a similar 
error:

py> time.strptime(None)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.3/_strptime.py", line 494, in 
_strptime_time
tt = _strptime(data_string, format)[0]
  File "/usr/local/lib/python3.3/_strptime.py", line 306, in _strptime
raise TypeError(msg.format(index, type(arg)))
TypeError: strptime() argument 0 must be str, not 


After reading the full traceback, I conclude that the time.strptime 
function calls _strptime._strptime. After importing _strptime and looking 
at the __file__ attribute, I see that it is a pure-python module. So, to 
answer your immediate question:

"explain why it [the time.strptime function] thinks I want an underscored 
name"

the answer is, it thinks you want an underscored name because you *do* 
need an underscored name. It is part of the implementation of 
time.strptime that it delegates some of the work to a private module 
_strptime.

As for why that is not available under mod_wsgi module, but is available 
when running under the normal Python environment, I have looked at the 
_strptime.py source code and nothing stands out to explain why the 
_strptime function might not be defined. So that seems like a question 
about mod_wsgi. I suggest you start here:

http://code.google.com/p/modwsgi/wiki/WhereToGetHelp

If you do get an answer, please post it here as well, so others in the 
future who stumble across this thread will see the answer.

Good luck!



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


Re: Command Line Progress Bar

2012-12-26 Thread xDog Walker
On Tuesday 2012 December 25 22:17, Kevin Anthony wrote:
> Hello,
> I'm writing a file processing script(Linux), and i would like to have a
> progress bar.  But i would also like to be able to print messages.  Is
> there a simple way of doing this without implementing something like
> ncurses?
http://pypi.python.org/pypi/progress
-- 
Yonder nor sorghum stenches shut ladle gulls stopper torque wet 
strainers.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Twisted-Python] Twisted 12.3.0 released

2012-12-26 Thread Laurens Van Houtven
Yay! Thanks for an awesome Christmas present Thomas :)


On Wed, Dec 26, 2012 at 2:21 PM, Thomas Hervé  wrote:

> On behalf of Twisted Matrix Laboratories, I am pleased to announce, in
> extremis, the release of Twisted 12.3.
>
> 161 tickets are closed by this release, with the following highlights:
>
>  * Support for local parallel testing in trial
>
>  * A new "react" function to easily run a single asynchronous function
> in a script with the reactor.
>
>  * Partial support for Python 3.3.
>
> Note that only Python 2.7 is supported on Windows now. We also require
> zope.interface 3.6.0 or newer.
>
>
> For more information, see the NEWS file here:
>
>  http://twistedmatrix.com/Releases/Twisted/12.3/NEWS.txt
>
>
> Download it now from:
>
>  http://pypi.python.org/packages/source/T/Twisted/Twisted-12.3.0.tar.bz2or
>
>
> http://pypi.python.org/packages/2.7/T/Twisted/Twisted-12.3.0.win32-py2.7.msi
>
>
> Thanks to the supporters of Twisted via the Software Freedom Conservancy
> and to the many contributors for this release.
>
> --
> Thomas
>
> ___
> Twisted-Python mailing list
> twisted-pyt...@twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>



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


Re: How to get time.strptime()?

2012-12-26 Thread Gnarlodious
Thanks for the help.
This error only occurs on my devbox which is running Py 3.3.0:

print(time.__file__, file=sys.stderr)
/usr/local/python-3.3.0/frameworks/Python.framework/Versions/3.3/lib/python3.3/lib-dynload/time.so
 
which looks normal to me.
The server box, which is running Py 3.1.3, says this:
/usr/local/python-3.1.3/frameworks/Python.framework/Versions/3.1/lib/python3.1/lib-dynload/time.so

Also of possible relevance is that my server is running mod_wsgi 3.3, while my 
devbox is running mod_wsgi 3.4. However I had a discussion with Dumpleton who 
decided it is a Python problem:
https://groups.google.com/forum/#!topic/modwsgi/9MF2ixebvfg

I don't know how to get any sort of traceback out of mod_wsgi. The script runs 
normally as a single-page CGI script but the error only occurs when imported as 
a module. 

Exactly  what I am saying is this:
import time
print(time.strptime("00", "%y"), file=sys.stderr)
--> No module named 'time.strptime'

But this works normally:
print(time.time(), file=sys.stderr)
--> 1356549188.368575

I can say this and see 'strptime' in the list of functions:
print(dir(time), file=sys.stderr)
--> ['_STRUCT_TM_ITEMS', '__doc__', '__file__', '__loader__', '__name__', 
'__package__', 'altzone', 'asctime', 'clock', 'ctime', 'daylight', 
'get_clock_info', 'gmtime', 'localtime', 'mktime', 'monotonic', 'perf_counter', 
'process_time', 'sleep', 'strftime', 'strptime', 'struct_time', 'time', 
'timezone', 'tzname', 'tzset']

So I am stumped.

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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-26 Thread Michael Torrie
On 12/25/2012 04:42 PM, Rick Johnson wrote:
> What IS a variable Dennis?
> #
> 
> #Variable (ComputerScience)#
> 

Found the reference you are quoting here.  It's from wikipedia.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-26 Thread Michael Torrie
On 12/25/2012 04:42 PM, Rick Johnson wrote:
> With that accurate definition in mind you can now understand how
> Python classes CAN and DO have variables, just as Python modules have
> variables; psst: they're called "global variables"!

Nice ascii graphic, but citation needed.  What CS text book are you
quoting from?

> Now, whilst i don't believe we should haphazardly re-define the
> definition of CS terms (or worse, re-invent the wheel by inventing
> new terms when perfectly good terms exist) I DO believe we should
> interpret these terms in their current context.

Good to have you back, Rick.  I think.  Sounds like you need to go back
and review your computer language theory CS class that you took in
University if you want to appeal to authority and definitions.  I was
taught very clearly what Dennis articulated.  We spent about 2 weeks
going over the difference between variables, names of variables,
binding, and passing.  And implementing everything in Scheme.  Good
days.  And we reviewed that again in my computer algorithms class.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Password hash

2012-12-26 Thread Ian Kelly
On Tue, Dec 25, 2012 at 8:40 PM, Ramchandra Apte  wrote:
> On Monday, 24 December 2012 08:08:12 UTC+5:30, Robert Montgomery  wrote:
>> I am writing a script that will send an email using an account I set up
>>
>> in gmail. It is an smtp server using tls on port 587, and I would like
>>
>> to use a password hash in the (python) script for login rather than
>>
>> plain text. Is this do-able? Details please.
>
> No. The password is encrypted with TLS I think so I believe you shouldn't 
> worry much about security.

The smtplib module automatically uses CRAM-MD5 for authentication if
it is available.  If you wanted to use some other hashing scheme then
I guess you would have to implement it yourself by overriding
SMTP.login, or find another SMTP module that already supports it.

The above comment about security is bad advice.  Security is all about
layers.  Just because the data stream is already encrypted (read:
decryptable) does not mean that password digests are a waste of time.
In fact, the two techniques are usually considered complementary:  the
encryption process protects your application data, while the password
hashing protects your authentication details.
-- 
http://mail.python.org/mailman/listinfo/python-list


Why is pexpect acting funny with sendline() and expect()?

2012-12-26 Thread saqib . ali . 75
I am running Solaris 5-10, python 2.6.2 and pexpect 2.4

I have the very simple python script below which exercises the functionality of 
sending and receiving text from the shell.

My understanding is that pexepect([pexpect.TIMEOUT, x,y,z], timeout=w) will 
return the index of the match that it found *since the last time pexpect was 
called*, but if it takes longer than w seconds, it will return 0.


Here is my very simple script:


#!/usr/bin/env python

import pexpect
myPrompt = " % "

myShell = pexpect.spawn("/bin/tcsh")
print "Sending 'JUNK-0' to shell"
x = myShell.sendline("JUNK-0")
y = myShell.expect([pexpect.TIMEOUT], timeout=1)   
print "y = %s" % y
print myShell.before 
print "=" * 80
print "\n\n"
 
for i in range(2):
print "i = %d" % (i+1)
print "Sending 'JUNK-%d' to shell" % (i+1)
x = myShell.sendline("JUNK-%d" % (i+1))
y = myShell.expect([pexpect.TIMEOUT, myPrompt], timeout=10)  
print "y = %s" % y
print myShell.before
print "=" * 80
print "\n\n"



FYI, my shell prompt is "myMachine % ", however in this script I have simply 
used " % " to keep it generic.

When I run it, I see the following output: 




Sending 'JUNK-0' to shell
y = 0
JUNK-0
myMachine % JUNK-0
JUNK-0: Command not found.
myMachine % 




i = 1
Sending 'JUNK-1' to shell
y = 1
JUNK-0
myMachine 




i = 2
Sending 'JUNK-2' to shell
y = 1
JUNK-0
JUNK-0: Command not found.
myMachine 





Why do I see "JUNK-0" consistently recurring in the output? It should be 
consumed by the first myShell.expect() statement, but it keeps showing up. Why??
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Keeping a Tkinter GUI alive during a long running process

2012-12-26 Thread Russell E. Owen
In article ,
 Kevin Walzer  wrote:

> I maintain a Tkinter application that's a front-end to to a package 
> manger, and I have never been able to find a way to keep the app from 
> locking up at some point during the piping in of the package manager's 
> build output into a text widget. At some point the buffer is overwhelmed 
> and the app simply can't respond anymore, or writes data to the text 
> widget after locking up for a period.
> 
> I've long used the typical Tkinter design pattern of opening a pipe to 
> the external command, and letting it do its thing. However, after a 
> time, this locks up the app. If I try to throttle the buffer with some 
> combination of "update" or "after" or "update_idletasks," that keeps the 
> data flowing, but it comes in too slowly and keeps flowing in long after 
> the external process has terminated.
> 
> Below is a sample function that illustrates how I approach this issue. 
> Can someone suggest a better approach?
> 
>   #install a fink package
>  def installPackage(self):
> 
>  self.package = self.infotable.getcurselection()
>  if not self.package:
>  showwarning(title='Error', message='Error', detail='Please 
> select a package name.', parent=self)
>  return
>  else:
>  self.clearData()
>  self.packagename = self.package[0][1]
>  self.status.set('Installing %s' % self.packagename)
>  self.setIcon(self.phynchronicity_install)
>  self.playSound('connect')
>  self.showProgress()
>  self.file = Popen('echo %s | sudo -S %s -y install %s' % 
> (self.passtext, self.finkpath.get(), self.packagename), shell=True, 
> bufsize=0, stdout=PIPE).stdout
>  for line in self.file:
>  self.inserturltext(line)
>  self.after(5000, self.update_idletasks)

I suggest you use the threading or multiprocessing module: call 
subprocess.Popen in the spawned thread or process, read stdout in a 
tight loop write the result into a queue. Then have your main process 
asynchronously read the queue using polling.

It sounds a bit complicated, but in lieu of a way to asynchronously read 
the stdout pipe, I don't know what else to do that's safe.

Another option to consider is to use Twisted framework, which has its 
own support for running tasks. However, if you are not using Twisted 
already, it's a big addition.

-- Russell

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


RE: How to get time.strptime()?

2012-12-26 Thread Nick Cash
> Error: AttributeError: 'module' object has no attribute '_strptime'
> 
> This problem is driving me crazy. It only happens in Python 3.3.0,
> while on my server running 3.1.3 it behaves as expected. When I try to
> access time.strptime() it errors with
> 
> AttributeError: 'module' object has no attribute '_strptime'.
> 
> This error only occurs under mod_wsgi, when running as a one-shot
> webapp it behaves normally. All other functionalities of the time
> module are normal.

I've run into this issue in the past with Python 2.6 (or maybe 2.7) and 
mod_python. My problem was that datetime.strptime imported _strptime at 
runtime, and multiple threads trying to import it at the same time broke an 
internal import lock.

I was able to work around this by simply importing _strptime myself at server 
startup time. This may or may not work for you.

See also: http://code.google.com/p/modwsgi/issues/detail?id=177 and 
http://www.mail-archive.com/python-list@python.org/msg248664.html 


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


Can you please help me?

2012-12-26 Thread bobflipperdoodle
I really hope you can help! 
 
I need to create a program where the user can order any combination and 
quantity of 3 products. I then offer a 10% discount if the customer correctly 
answers a trivia question.  After that, there are 3 choices for shipping.
 
I have most of the program completed but I'm struggling with the most important 
parts :/  I get the total of multiple orders of the same item, but we can't 
figure out how to total the entire order - before discounts and shipping - and 
then where to put any code referring back to the trivia question. Can somebody 
please help me with this? I would really appreciate it!

This is the code:


shop_again = 'y'

print("Welcome to the Star Wars Shop!")
customer = eval(input("Is there a customer in line? (1 = yes, 2 = no)> "))
while shop_again == 'y':
if (customer == 2):
print("Welcome to the Star Wars Memorabilia Shop!")
customer = eval(input("Is there a customer in line? (1 = yes, 2 = no)> 
"))

elif (customer == 1):
print("Please select an item to update your order and any other number 
to check out.")
print("Yoda Figure: $10 each.")
print("Star Wars Movie DVD: $20 each.")
print("Death Star Lego Set: $200 each.")
print(" 1 for Yoda Figure")
print(" 2 for Star Wars Movie DVD")
print(" 3 for Death Star Lego Set")
order = eval(input("Order: "))


if (order == 1):
yoda = eval(input("How many Yoda Figures do you want? : "))
total = 10 * yoda
print("Total:", total)
print("Current order:", yoda, "at", total)
if (order == 2):
movie = eval(input("How many Star Wars Movie DVDs do you want? : "))
total = 20 * movie
print("Total:", total)
print("Current order:", movie, "at", total)
if (order == 3):
legos = eval(input("How many Death Star Lego Sets do you want? : "))
total = 200 * legos
print("Total:", total)
print("Current order:", legos, "at", total)

shop_again = input("Would you like to keep shopping? 'Y' for yes, 'N' for 
no: ")
print()
print("Your order before shipping and discounts: ",total)
print()
print("Answer a trivia question for a discount!")
discount = eval(input("On what planet did Yoda live when Luke Skywalker first 
met him? 1) Earth 2) Dagobah 3) Pluto :"))
if (discount == 1):
print("Sorry, that answer was wrong!")
if (discount == 2):
print("That's correct, you get a 10% discount!")
if (discount == 3):
print("Sorry, that answer was wrong!")
print()
if (discount == 2):
(total * .9)
print("Your total before shipping: ",total)


print("1) Regular Shipping: 3-4 business days, $5.00 per $50 ordered. 2) 
Express Shipping: overnight, $10 per $50 ordered. 3) Super Saver Shipping: 7-10 
business days, free.")
shipping = eval(input("Please select the shipping method you want: "))

if (shipping == 1):

total == total % 50
total == total * 5
print("Your total is: ",total)
if (shipping == 2):
total == total/50
total == total % 50
total == total * 10
print("Your total is: ",total)
if(shipping == 3):
print("Your total is: ",total)
print()
print("Thanks for shopping here! Please come again!")
 
-- 
http://mail.python.org/mailman/listinfo/python-list


running gui py script

2012-12-26 Thread Verde Denim
I'm learning py in this environment -
PyCrust 0.9.5 - The Flakiest Python Shell
Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
[GCC 4.4.5] on linux2

When I type a tkinter program in pycrust (or pyshell), it executes as
expected, but when I call it from a command line, it doesn't. What I'm
getting back is this -

python my_first_gui_in_py.py
Traceback (most recent call last):
  File "my_first_gui_in_py.py", line 2, in 
class myapp_tk(Tkinter.Tk):
  File "my_first_gui_in_py.py", line 14, in myapp_tk
app = myapp_tk(None)
NameError: name 'myapp_tk' is not defined

Trying to call the file in pycrust doesn't seem to work for me either.
If I invoke pycrust either as
$ pycrust ./my_first_gui_in_py.py or
$ pycrust < ./my_first_gui_in_py.py

the editor opens, but with an empty buffer.

What is it that I'm not understanding?

Thanks, as always for the help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Please help if you can!

2012-12-26 Thread bobflipperdoodle
I really hope you can help! 
  
I need to create a program where the user can order any combination and 
quantity of 3 products. I then offer a 10% discount if the customer correctly 
answers a trivia question.  After that, there are 3 choices for shipping. 
  
I have most of the program completed but I'm struggling with the most important 
parts :/  I can get the total with discount to calculate only if i order every 
item. I also cant figure out how to get the shipping calculated correctly, 
including where to put any code referring back to the trivia question. Can 
somebody please help me with this? I would really appreciate it! 

Here is the code:

shop_again = 'y'

print("Welcome to the Star Wars Shop!")
customer = eval(input("Is there a customer in line? (1 = yes, 2 = no)> "))
while shop_again == 'y':
if (customer == 2):
print("Welcome to the Star Wars Memorabilia Shop!")
customer = eval(input("Is there a customer in line? (1 = yes, 2 = no)> 
"))

elif (customer == 1):
print("Please select an item to update your order and any other number 
to check out.")
print("Yoda Figure: $10 each.")
print("Star Wars Movie DVD: $20 each.")
print("Death Star Lego Set: $200 each.")
print(" 1 for Yoda Figure")
print(" 2 for Star Wars Movie DVD")
print(" 3 for Death Star Lego Set")
order = eval(input("Order: "))


if (order == 1):
yoda = eval(input("How many Yoda Figures do you want? : "))
yodatotal = 10 * yoda
print("Total:", yodatotal)
print("Current order:", yoda, "for", yodatotal)
if (order == 2):
movie = eval(input("How many Star Wars Movie DVDs do you want? : "))
movietotal = 20 * movie
print("Total:", movietotal)
print("Current order:", movie, "for", movietotal)
if (order == 3):
legos = eval(input("How many Death Star Lego Sets do you want? : "))
legototal = 200 * legos
print("Total:", legototal)
print("Current order:", legos, "for", legototal)

shop_again = input("Would you like to keep shopping? 'Y' for yes, 'N' for 
no: ")
print()
print("Yoda Figures: ",yoda,"Totaling", yodatotal)
print("Star Wars Movies: ", movie,"Totaling", movietotal)
print("Death Star Legos: ", legos,"Totaling", legototal)
itemstotal = yodatotal + movietotal + legototal
print("Your order before shipping and discounts: ",itemstotal)
print()
print("Answer a trivia question for a discount!")
discount = eval(input("On what planet did Yoda live when Luke Skywalker first 
met him? 1) Earth 2) Dagobah 3) Pluto :"))
if (discount == 1):
print("Sorry, that answer was wrong!")
if (discount == 2):
print("That's correct, you get a 10% discount!")
if (discount == 3):
print("Sorry, that answer was wrong!")
print()
if (discount == 1):
total = itemstotal
print("Your total before shipping: ",total)

if (discount == 2):
total = itemstotal * .9
print("Your total before shipping: ",total)

if (discount == 3):
total = itemstotal
print("Your total before shipping: ",total)


print("1) Regular Shipping: 3-4 business days, $5.00 per $50 ordered. 2) 
Express Shipping: overnight, $10 per $50 ordered. 3) Super Saver Shipping: 7-10 
business days, free.")
shipping = eval(input("Please select the shipping method you want: "))

if (shipping == 1):

total == total % 50
total == total * 5
print("Your total is: ",total)
if (shipping == 2):
total == total/50
total == total % 50
total == total * 10
print("Your total is: ",total)
if(shipping == 3):
print("Your total is: ",total)
print()
print("Thanks for shopping here! Please come again!")
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can you please help me?

2012-12-26 Thread Mitya Sirenef

On 12/26/2012 04:40 PM, bobflipperdoo...@gmail.com wrote:

I really hope you can help!
  
I need to create a program where the user can order any combination and quantity of 3 products. I then offer a 10% discount if the customer correctly answers a trivia question.  After that, there are 3 choices for shipping.
  
I have most of the program completed but I'm struggling with the most important parts :/  I get the total of multiple orders of the same item, but we can't figure out how to total the entire order - before discounts and shipping - and then where to put any code referring back to the trivia question. Can somebody please help me with this? I would really appreciate it!


This is the code:


shop_again = 'y'

print("Welcome to the Star Wars Shop!")
customer = eval(input("Is there a customer in line? (1 = yes, 2 = no)> "))
while shop_again == 'y':
 if (customer == 2):
 print("Welcome to the Star Wars Memorabilia Shop!")
 customer = eval(input("Is there a customer in line? (1 = yes, 2 = no)> 
"))

 elif (customer == 1):
 print("Please select an item to update your order and any other number to 
check out.")
 print("Yoda Figure: $10 each.")
 print("Star Wars Movie DVD: $20 each.")
 print("Death Star Lego Set: $200 each.")
 print(" 1 for Yoda Figure")
 print(" 2 for Star Wars Movie DVD")
 print(" 3 for Death Star Lego Set")
 order = eval(input("Order: "))


 if (order == 1):
 yoda = eval(input("How many Yoda Figures do you want? : "))
 total = 10 * yoda
 print("Total:", total)
 print("Current order:", yoda, "at", total)
 if (order == 2):
 movie = eval(input("How many Star Wars Movie DVDs do you want? : "))
 total = 20 * movie
 print("Total:", total)
 print("Current order:", movie, "at", total)
 if (order == 3):
 legos = eval(input("How many Death Star Lego Sets do you want? : "))
 total = 200 * legos
 print("Total:", total)
 print("Current order:", legos, "at", total)
 
 shop_again = input("Would you like to keep shopping? 'Y' for yes, 'N' for no: ")

 print()
print("Your order before shipping and discounts: ",total)
print()
print("Answer a trivia question for a discount!")
discount = eval(input("On what planet did Yoda live when Luke Skywalker first met 
him? 1) Earth 2) Dagobah 3) Pluto :"))
if (discount == 1):
 print("Sorry, that answer was wrong!")
if (discount == 2):
 print("That's correct, you get a 10% discount!")
if (discount == 3):
 print("Sorry, that answer was wrong!")
print()
if (discount == 2):
 (total * .9)
 print("Your total before shipping: ",total)
 


print("1) Regular Shipping: 3-4 business days, $5.00 per $50 ordered. 2) Express 
Shipping: overnight, $10 per $50 ordered. 3) Super Saver Shipping: 7-10 business days, 
free.")
shipping = eval(input("Please select the shipping method you want: "))

if (shipping == 1):
 
 total == total % 50

 total == total * 5
 print("Your total is: ",total)
if (shipping == 2):
 total == total/50
 total == total % 50
 total == total * 10
 print("Your total is: ",total)
if(shipping == 3):
 print("Your total is: ",total)
print()
print("Thanks for shopping here! Please come again!")
  



I think before worrying about totals, et cetera, you need
to approach this in a more modular way. Here's an
example of using 3 functions to do the product menu,
where each choice gets 1 count of product, without
option to specify quantity:


from collections import defaultdict

prompt  = "> "
cart= defaultdict(int)
product_tpl = "%d) %-15s [ $%d ]"
products= {
1: ("Yoda", 10),
2: ("DVD", 20),
3: ("Lego Set", 200)
}

def product_menu():
while True:
print("Select item to order, 'f' when finished.")
for pid, prod in products.items():
print(product_tpl % (pid, prod[0], prod[1]))

inp = input(prompt)
if inp == 'f': return
product = getproduct(inp)

if product : cart[product] += 1
else   : print("Invalid Input")
print()

def getproduct(inp):
try:
return products[int(inp)]
except (ValueError, KeyError):
return None

def main():
product_menu()

for (name, price), count in cart.items():
print("product: %s, price: %d, count: %d" % (name, price, count))
total = sum(price*count for (name, price), count in cart.items())
print("Total for the order is: $%d" % total)

main()


A few notes:

The code is a lot simpler when you define the collection of products
outside of the selection loop. It also means you can reuse the products
dict in other functions.

It's easier, usually, to work with 'while True' loops because you have
precise control of where it breaks, either with a break statement
or with a return. In the type of loop you used

Re: Can you please help me?

2012-12-26 Thread bobflipperdoodle
Thank you very much for your reply.  I actually just deleted this post as you 
were replying!  I had figured out a few things and then got confused about a 
few others :/  If you have a chance, can you look at the other post?  Thank 
you!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: running gui py script

2012-12-26 Thread Dave Angel
On 12/26/2012 03:07 PM, Verde Denim wrote:
> I'm learning py in this environment -
> PyCrust 0.9.5 - The Flakiest Python Shell
> Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
> [GCC 4.4.5] on linux2
>
> When I type a tkinter program in pycrust (or pyshell), it executes as
> expected, but when I call it from a command line, it doesn't. What I'm
> getting back is this -
>
> python my_first_gui_in_py.py
> Traceback (most recent call last):
>   File "my_first_gui_in_py.py", line 2, in 
> class myapp_tk(Tkinter.Tk):
>   File "my_first_gui_in_py.py", line 14, in myapp_tk
> app = myapp_tk(None)
> NameError: name 'myapp_tk' is not defined
>
> Trying to call the file in pycrust doesn't seem to work for me either.
> If I invoke pycrust either as
> $ pycrust ./my_first_gui_in_py.py or
> $ pycrust < ./my_first_gui_in_py.py
>
> the editor opens, but with an empty buffer.
>
> What is it that I'm not understanding?
Mainly that it helps to actually show your code, or at least as much of
it as you think we might be interested in.
Good job showing us the versions & os, and the full traceback.

No idea why it works in pycrust;  I've never used it, or pyshell.  It's
not clear what you mean by "typing in the shell".  if you mean you're
entering it in the interpreter, then I'd guess you didn't indent it the
same way as in the file.

But if it doesn't work at the command line, it's broken.  And my guess
is that you're trying to use the class inside its own definition. 
That's okay inside a method, but not inside the class initialization.  
For example, if you have

class myapp_tk(Tkinter.Tk):
  app = myapp_tk(None)

it's not valid.  Instead, do the following after the class definition is
complete:

myapp.app = myapp_tk(None)

BTW, it's customary to capitalize the first letter of a class name.

-- 

DaveA

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


Re: Can you please help me?

2012-12-26 Thread Mitya Sirenef

On 12/26/2012 06:21 PM, bobflipperdoo...@gmail.com wrote:

Thank you very much for your reply.  I actually just deleted this post as you 
were replying!  I had figured out a few things and then got confused about a 
few others :/  If you have a chance, can you look at the other post?  Thank 
you!!



Fortunately, my reply is as relevant to the 2nd post just as much as to 
the 1st :-).

I must be able to see future!

--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

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


Re: Please help if you can!

2012-12-26 Thread Dave Angel
On 12/26/2012 06:04 PM, bobflipperdoo...@gmail.com wrote:
> I really hope you can help! 
>  

Please use the existing thread when you're continuing to ask the same
question.

This mailing list has no way to delete messages.

So what changes are there between the two versions of the code?  Are
they marked somehow?

Have you absorbed and implemented the very useful comments made by
Mitya?  Whenever you find yourself doing exactly the same code many
times, chances are high that you should factor it into a function, or a
class.


-- 

DaveA

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


Re: Please help if you can!

2012-12-26 Thread Joshua Landau
THIS IS A LONG POST, BUT IF YOU WANT TO LEARN YOU SHOULD READ IT. SERIOUSLY.

UNLIKE Mitya Sirenef's THIS DOES NOT ASSUME MORE KNOWLEDGE THAN IS IN YOUR
POST ALREADY, ALTHOUGH HIS IS DEFINITELY BETTER OVERALL. AS SUCH, THERE ARE
NO FUNCTIONS.

OK. There are several small errors in here, but there's nothing too large
or worth much worry.

On 26 December 2012 21:40,  wrote:

> I really hope you can help!
>
> I need to create a program where the user can order any combination and
> quantity of 3 products. I then offer a 10% discount if the customer
> correctly answers a trivia question.  After that, there are 3 choices for
> shipping.
>
> I have most of the program completed but I'm struggling with the most
> important parts :/  I get the total of multiple orders of the same item,
> but we can't figure out how to total the entire order - before discounts
> and shipping - and then where to put any code referring back to the trivia
> question. Can somebody please help me with this? I would really appreciate
> it!
>

You write that you "need" to do this, which may hint that this is some sort
of homework. If so, it's generally a nice thing to say as much. That said,
as long as you've given a good shot at it it's normally fine.


> This is the code:
>

My *very first* thought about this code is that it's really badly spaced.
Don't put lines together so much! [https://gist.github.com/4383950] shows
how much nicer things look when they're partitioned more. You may not
agree, but it took about 10 seconds and I prefer it.


> shop_again = 'y'
>

Hold on! Hold on!
shop_again should have a True/False value. It is screaming to be a boolean.
"y" is a letter, not a boolean. Thus:

shop_again = True

This is important because you don't really want to get confused with all
your types. What if shop_again was later changed to be True when a button
was clicked. Why on earth would you set it to "y"? You'd set it to True.
Thus, the sensible option is to have your types right from the very start.

print("Welcome to the Star Wars Shop!")
> customer = eval(input("Is there a customer in line? (1 = yes, 2 = no)> "))
>

eval(input(TEXT)) is a *bad* idea.

First of all, eval is really dangerous. Answer "yes" instead and it'll just
crash. Answer True and it'll run... BUT do *neither* the if or the elif!
That's *bad*.
Secondly, you don't need it. Your:

"if(customer == 1)" could be "if(customer == '1')", which would work
without the eval.

And then you've got the standard of "Y/N". So a better question would be:

customer = input("Is there a customer in line? [Y/N]> ")

Finally, you want to accept "Y" *and* "y", so you'd really want:

customer = input("Is there a customer in line? [Y/N]> ").lower()

-
customer = input("Is there a customer in line? [Y/N]> ").lower()
Because customer really deserves to be boolean [True/False], you'd want to
change it immediately.

customer = (customer == "y")

This second line assumes that all non-"y"s are False, but that's a folly
you'll have to live with for now.

while shop_again == 'y':
>

If you've changed shop_again to be boolean:

while shop_again:

Some people don't get how this line would make sense. But it does. The
"while" statement only cares if it's value it gets is "truthy". Here are
lots of truthy things:

"y" == "y"
True
False == False
not False
"egg loaf"
[1, 2, 1, False, False]

and here are some falsy things:

"n" == "y"
False
True == False
not True
""
[]

If this makes no sense, please just say.

if (customer == 2):
>

Again, if you've done my changes from above:

if not customer:


> print("Welcome to the Star Wars Memorabilia Shop!")
> customer = eval(input("Is there a customer in line? (1 = yes, 2 =
> no)> "))
>

Again:

customer = input("Is there a customer in line? [Y/N]> ").lower()
customer = (customer == "y")

BUT HOLD ON!

Run your program and then answer "2" twice. What happens? It's not good.

The problem is that answering "2" to this second one doesn't skip the loop!

x = ASK
LOOP:
if not x:
ASK
if x:
STUFF
MORE STUFF

Where you want:

x = ASK
LOOP:
if not x:
ASK
if x:
STUFF
MORE STUFF

or (even better):

while not x:
x = ASK
LOOP:
STUFF
MORE STUFF

The second is what I've just decided to call the "ask-until-yes" model.
Basically, you ask until you get a "yes", so you don't have to put the loop
anywhere else. By the time the first loop is over, you *know* that x is
True!

elif (customer == 1):
>

Again, if you've done my changes from above:

elif customer:


> print("Please select an item to update your order and any other
> number to check out.")
> print("Yoda Figure: $10 each.")
> print("Star Wars Movie DVD: $20 each.")
> print("Death Star Lego Set: $200 each.")
> print(" 1 for Yoda Figure")
> print(" 2 for Star Wars Movie DVD")
> print(" 3 for Death Star Lego Set")
> order = eval(input("Order: "))
>

Again:

orde

Re: Can you please help me?

2012-12-26 Thread Ian Kelly
On Wed, Dec 26, 2012 at 4:21 PM,   wrote:
> Thank you very much for your reply.  I actually just deleted this post as you 
> were replying!  I had figured out a few things and then got confused about a 
> few others :/  If you have a chance, can you look at the other post?  Thank 
> you!!

You can't actually delete posts, because this is a Usenet newsgroup
and mailing list.  The Google group is just a gateway to the
newsgroup.  There are incidentally a number of users who filter out
all posts from Google Groups due to the high level of spam posts
originating from there, so you would be likely to get a better
response if you ditched the Google group and posted directly to
comp.lang.python or python-list@python.org instead.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help if you can!

2012-12-26 Thread bobflipperdoodle
First, sorry for starting a new post - I didn't want anyone to have to read 
through the whole first one when the questions were completely different :/

Second, I honestly have no idea how to answer your questions.  I am a sophomore 
in high school and I am trying to learn this on my own because my teacher is 
not very good at explaining things.  

i just cant figure out how to get the total when an order is placed without the 
customer ordering at least one of each item.  I also can't figure out how to 
get the shipping to calculate correctly. It is an intro class and we are using 
just the basics. Most of what Mitya said is stuff I've never seen before, 
although I am very grateful for her response, I am supposed to use only what 
the teacher "taught".

Sorry if I frustrated you.  I'm just a kid trying to learn. Any help is 
appreciated
 

On Wednesday, December 26, 2012 6:49:27 PM UTC-5, Dave Angel wrote:
> On 12/26/2012 06:04 PM,  wrote:
> 
> > I really hope you can help! 
> 
> >  
> 
> 
> 
> Please use the existing thread when you're continuing to ask the same
> 
> question.
> 
> 
> 
> This mailing list has no way to delete messages.
> 
> 
> 
> So what changes are there between the two versions of the code?  Are
> 
> they marked somehow?
> 
> 
> 
> Have you absorbed and implemented the very useful comments made by
> 
> Mitya?  Whenever you find yourself doing exactly the same code many
> 
> times, chances are high that you should factor it into a function, or a
> 
> class.
> 
> 
> 
> 
> 
> -- 
> 
> 
> 
> DaveA

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


Re: Please help if you can!

2012-12-26 Thread bobflipperdoodle
I cannot tell you how grateful I am that you took the time to do all of this.  
I have been working on it all day and you are a better teacher in a few minutes 
than my teacher has been in 4 months.  THANK YOU!

And thank you again, Mitya.  I really appreciate your time and effort too!  
Someday I'll be advanced enough to understand it lol

I'm going to take a break and work on it more tomorrow.  I'll be back.

Thank you!


On Wednesday, December 26, 2012 6:57:39 PM UTC-5, Joshua Landau wrote:
> THIS IS A LONG POST, BUT IF YOU WANT TO LEARN YOU SHOULD READ IT. SERIOUSLY.
> 
> 
> UNLIKE Mitya Sirenef's THIS DOES NOT ASSUME MORE KNOWLEDGE THAN IS IN YOUR 
> POST ALREADY, ALTHOUGH HIS IS DEFINITELY BETTER OVERALL. AS SUCH, THERE ARE 
> NO FUNCTIONS.
> 
> 
> 
> OK. There are several small errors in here, but there's nothing too large or 
> worth much worry.
> 
> 
> 
> On 26 December 2012 21:40,  wrote:
> 
> 
> I really hope you can help!
> 
> I need to create a program where the user can order any combination and 
> quantity of 3 products. I then offer a 10% discount if the customer correctly 
> answers a trivia question.  After that, there are 3 choices for shipping.
> 
> 
> 
> I have most of the program completed but I'm struggling with the most 
> important parts :/  I get the total of multiple orders of the same item, but 
> we can't figure out how to total the entire order - before discounts and 
> shipping - and then where to put any code referring back to the trivia 
> question. Can somebody please help me with this? I would really appreciate it!
> 
> 
> 
> 
> 
> You write that you "need" to do this, which may hint that this is some sort 
> of homework. If so, it's generally a nice thing to say as much. That said, as 
> long as you've given a good shot at it it's normally fine.
> 
> 
>  This is the code:
> 
> 
> 
> 
> 
> My *very first* thought about this code is that it's really badly spaced. 
> Don't put lines together so much! [https://gist.github.com/4383950] shows how 
> much nicer things look when they're partitioned more. You may not agree, but 
> it took about 10 seconds and I prefer it.
> 
> 
>  shop_again = 'y'
> 
> 
> 
> 
> 
> Hold on! Hold on!
> shop_again should have a True/False value. It is screaming to be a boolean. 
> "y" is a letter, not a boolean. Thus:
> 
> 
> shop_again = True
> 
> 
> 
> 
> This is important because you don't really want to get confused with all your 
> types. What if shop_again was later changed to be True when a button was 
> clicked. Why on earth would you set it to "y"? You'd set it to True. Thus, 
> the sensible option is to have your types right from the very start.
> 
> 
> 
> print("Welcome to the Star Wars Shop!")
> 
> 
> customer = eval(input("Is there a customer in line? (1 = yes, 2 = no)> "))
> 
> 
> 
> eval(input(TEXT)) is a *bad* idea.
> 
> 
> First of all, eval is really dangerous. Answer "yes" instead and it'll just 
> crash. Answer True and it'll run... BUT do *neither* the if or the elif! 
> That's *bad*.
> 
> 
> Secondly, you don't need it. Your:
> 
> 
> "if(customer == 1)" could be "if(customer == '1')", which would work without 
> the eval.
> 
> 
> And then you've got the standard of "Y/N". So a better question would be:
> 
> 
> 
> 
> customer = input("Is there a customer in line? [Y/N]> ")
> 
> 
> Finally, you want to accept "Y" *and* "y", so you'd really want:
> 
> 
> 
> 
> customer = input("Is there a customer in line? [Y/N]> ").lower()
> 
> 
> 
> -
> customer = input("Is there a customer in line? [Y/N]> ").lower()
> 
> 
> 
> Because customer really deserves to be boolean [True/False], you'd want to 
> change it immediately.
> 
> 
> customer = (customer == "y")
> 
> 
> This second line assumes that all non-"y"s are False, but that's a folly 
> you'll have to live with for now.
> 
> 
> 
> while shop_again == 'y':
> 
> 
> 
> 
> 
> If you've changed shop_again to be boolean:
> 
> 
> while shop_again:
>  
> Some people don't get how this line would make sense. But it does. The 
> "while" statement only cares if it's value it gets is "truthy". Here are lots 
> of truthy things:
> 
> 
> 
> 
> "y" == "y"
> True
> False == False
> not False
> "egg loaf"
> [1, 2, 1, False, False]
> 
> 
> and here are some falsy things:
> 
> 
> 
> 
> "n" == "y"
> False
> True == False
> not True
> ""
> []
> 
> 
> If this makes no sense, please just say.
> 
> 
> 
>     if (customer == 2):
> 
> 
> 
> 
> 
> Again, if you've done my changes from above:
> 
> 
> 
> if not customer:
>  
> 
>         print("Welcome to the Star Wars Memorabilia Shop!")
>         customer = eval(input("Is there a customer in line? (1 = yes, 2 = 
> no)> "))
> 
> 
> 
> Again:
> 
> 
> 
> 
> customer = input("Is there a customer in line? [Y/N]> ").lower()
> 
> customer = (customer == "y")
> 
>  
> BUT HOLD ON!
> 
> 
> Run your program and then answer "2" twice. What happens? It's not good.
> 
> 
> 
> 
> The problem is that answering "2" to this second one doesn't skip the loop!
> 
> 
> x = AS

Re: Please help if you can!

2012-12-26 Thread Chris Angelico
On Thu, Dec 27, 2012 at 11:04 AM,   wrote:
> Second, I honestly have no idea how to answer your questions.  I am a 
> sophomore in high school and I am trying to learn this on my own because my 
> teacher is not very good at explaining things.

Unfortunately, there are a great many bad programming courses out
there - either because the course material itself is flawed, or
because it's being delivered by someone who isn't good at teaching.
But fortunately, with Python, you don't need a course at all! Check
this out:

http://docs.python.org/3/tutorial/index.html

You may even be able to work through the tutorial (actually _do_ the
examples, btw) in less time than it would take to solve your problem
by asking here - it takes time to formulate questions, more time to
wait for responses, and then the response may or may not make good
sense to you. It's an excellent tutorial; I strongly recommend it to
people new to Python, whether they're experienced programmers with
other languages or totally new to coding.

> i just cant figure out how to get the total when an order is placed without 
> the customer ordering at least one of each item.  I also can't figure out how 
> to get the shipping to calculate correctly. It is an intro class and we are 
> using just the basics. Most of what Mitya said is stuff I've never seen 
> before, although I am very grateful for her response, I am supposed to use 
> only what the teacher "taught".
>
> Sorry if I frustrated you.  I'm just a kid trying to learn. Any help is 
> appreciated

The rule that you should use only what you've been taught is a
restriction, and yes, restrictions may feel annoying. But it actually
makes your task easier. Why? Because you have a guarantee (assuming
the course material isn't so fundamentally flawed as to make the task
impossible) that the goal can be achieved with just those tools. You
probably haven't, for instance, been taught about building a dispatch
table using a dictionary and a collection of functions, so you don't
need to worry about coding that way (as an aside, it's a quite viable
way to write something like this).

Once you understand the problem AND understand the tools you're
working with, it's up to you to figure out how to combine your
available tools to solve the problem. That's a fundamental of all
programming and, truth to tell, all of life. But it starts with
understanding both halves, so to that end I think Mitya's post is
quite useful even if the code itself does things you "haven't been
taught". You'll just need to do some code massaging at the end.

Best of luck in the course. Try not to let it scare you off coding -
it's a wonderful world out here, unfathomable powah is unleashed by a
few keystrokes!

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


Re: Please help if you can!

2012-12-26 Thread Joshua Landau
On 27 December 2012 00:04,  wrote:

> First, sorry for starting a new post - I didn't want anyone to have to
> read through the whole first one when the questions were completely
> different :/
>
> Second, I honestly have no idea how to answer your questions.  I am a
> sophomore in high school and I am trying to learn this on my own because my
> teacher is not very good at explaining things.
>
> i just cant figure out how to get the total when an order is placed
> without the customer ordering at least one of each item.  I also can't
> figure out how to get the shipping to calculate correctly. It is an intro
> class and we are using just the basics. Most of what Mitya said is stuff
> I've never seen before, although I am very grateful for her response, I am
> supposed to use only what the teacher "taught".
>
> Sorry if I frustrated you.  I'm just a kid trying to learn. Any help is
> appreciated
>

There's no anger here, by the way. If we were unhappy with you, you'd know
;). But seriously, if we weren't just trying to help, we wouldn't reply. We
were just telling you some stuff you needed to know.

 I'm in school too, and I'm self taught. I also run a little club where I
teach people how to code, from scratch. I get where you're coming from, and
you should realise you're doing fine. We get a lot of newbies posting on
here, and I'm used to seeing code like this. The important part is that
your mistakes are small and self-contained. Those are the easy mistakes,
and they're the parts that you don't have to worry about.

FINALLY:
When you use Google Groups, your quotations look to us like this:

> This is something I said
>
> with lots of extra
>
> lines in the middle
>
> for no reason. Google
>
> Groups sucks, basically.

So please just delete the part where you quote other people. I think there
are other ways of quoting properly, but you might as well just not quote.
(When you quoted my post, the result was *literally* twice as long!)

Thanks, and good luck.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help if you can!

2012-12-26 Thread Mitya Sirenef

On 12/26/2012 07:04 PM, bobflipperdoo...@gmail.com wrote:

First, sorry for starting a new post - I didn't want anyone to have to read 
through the whole first one when the questions were completely different :/

Second, I honestly have no idea how to answer your questions.  I am a sophomore 
in high school and I am trying to learn this on my own because my teacher is 
not very good at explaining things.

i just cant figure out how to get the total when an order is placed without the customer 
ordering at least one of each item.  I also can't figure out how to get the shipping to 
calculate correctly. It is an intro class and we are using just the basics. Most of what 
Mitya said is stuff I've never seen before, although I am very grateful for her response, 
I am supposed to use only what the teacher "taught".



I'm sorry to hear that, I just want to clarify - the teacher did not yet 
cover

the use of lists, dictionaries and functions?

If that's the case, I have to agree with you that he's probably not a very
good teacher because this task can be done much easier and better
with those 3 concepts, all of which are very easy. If you are barred from
using them, Joshua's post will be most helpful.

If you are curious about the 3 concepts I mentioned, they are covered
in the official python tutorial, but the quick rundown is:

list: a list of items, e.g. a shopping list:

shoplist = ["tea", "cake", "blueberries"]

dictionary: a collection of keys/values, like words/definitions in a 
dictionary:


shopping_cart = {"yoda": 3, "dvd": 5}  # 3 of yoda figures, 5 dvds


function: a way to group a bunch of code together:

def main():
  # do something
  # do something else
  # la la la

main()

The nice thing about functions is that if you need to repeat
something, let's say, two thousand times, you just call the
function two thousand times, e.g.:

for x in range(2000): main()

Which is much easier than typing in two thousand copies of the same code
 (don't ask me how I know!)

 - mitya


--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

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


Re: Please help if you can!

2012-12-26 Thread Chris Angelico
On Thu, Dec 27, 2012 at 11:45 AM, Joshua Landau
 wrote:
> FINALLY:
> When you use Google Groups, your quotations look to us like this:
>
>> This is something I said
>>
>> with lots of extra
>>
>> lines in the middle
>>
>> for no reason. Google
>>
>> Groups sucks, basically.
>
> So please just delete the part where you quote other people. I think there
> are other ways of quoting properly, but you might as well just not quote.
> (When you quoted my post, the result was *literally* twice as long!)
>

One of the regulars on the list has posted a run-down of how to post
from Google Groups without annoying everyone, and among other things,
it recommends manually deleting all the blank lines. To my mind,
though, this would be insane and inane tedium. I recommend signing up
to the mailing list; see
http://mail.python.org/mailman/listinfo/python-list for details. (As
an aside, the mailing list is run by Mailman, which is written in
Python. So we use Python to discuss Python.)

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


Re: Custom alphabetical sort

2012-12-26 Thread Joshua Landau
On 25 December 2012 06:18, Dave Angel  wrote:

> On 12/24/2012 06:19 PM, Pander Musubi wrote:

 

>  > Thanks very much for this efficient code.
>
> Perhaps you missed Ian Kelly's correction of Thomas Bach's approach:
>
> d = { k: v for v, k in enumerate(cs) }
>
>
> def collate(x):
> return list(map(d.get, x))
>
> sorted(data, key=collate)
>
> I'd use Ian Kelly's approach.


Well, he was first to it :P


> It's not only more compact,


I take offence* here! The only difference was "list(map(d.get, x))" vs
"[hashindex[s] for s in string]" (11 chars) and my longer naming scheme. If
you really care enough about those to sway your judgement, shame on you! ;)

* Not really

it shouldn't
> give an exception for a character not in the table.


That was a choice, not a bug. I didn't want undefined behaviour, so I
thought I'd leave it to crash on "bad" input than sort in a way that may be
unwanted. Even Ian Kelly gave this as way of coding it.


> At least, not for
> Python 2.x.  I'm not sure about Python 3, since it can give an exception
> comparing None to int.



Please not that this post was done in humour (but with truth) to delay
sleep. No offence to Ian or you intended ;).

Happy After-Christmas!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help if you can!

2012-12-26 Thread Mitya Sirenef

On 12/26/2012 08:00 PM, Chris Angelico wrote:

On Thu, Dec 27, 2012 at 11:45 AM, Joshua Landau
 wrote:

FINALLY:
When you use Google Groups, your quotations look to us like this:


This is something I said

with lots of extra

lines in the middle

for no reason. Google

Groups sucks, basically.

So please just delete the part where you quote other people. I think there
are other ways of quoting properly, but you might as well just not quote.
(When you quoted my post, the result was *literally* twice as long!)


One of the regulars on the list has posted a run-down of how to post
from Google Groups without annoying everyone, and among other things,
it recommends manually deleting all the blank lines. To my mind,
though, this would be insane and inane tedium. I recommend signing up



I have to agree - I saw that howto as well and it occurred to me
that if we have to delete blank lines manually we might
as well use postal pigeons with tiny little papyrus scrolls -
at least those don't insert blank lines automatically!

 -m

--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

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


Re: Please help if you can!

2012-12-26 Thread Dennis
>
> My *very first* thought about this code is that it's really badly spaced.
> Don't put lines together so much! [https://gist.github.com/4383950] shows
> how much nicer things look when they're partitioned more. You may not
> agree, but it took about 10 seconds and I prefer it.
>
>

On another style note, you may want to take a look at this thread:

http://stackoverflow.com/questions/5611776/what-are-the-comprehensive-lint-checkers-for-python

Keeping your code style consistent and readable is a fundamental tenant of
Python development.

That link specifically points out PEP8:
http://www.python.org/dev/peps/pep-0008/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please help if you can!

2012-12-26 Thread Chris Angelico
On Thu, Dec 27, 2012 at 12:17 PM, Mitya Sirenef  wrote:
> I have to agree - I saw that howto as well and it occurred to me
> that if we have to delete blank lines manually we might
> as well use postal pigeons with tiny little papyrus scrolls -
> at least those don't insert blank lines automatically!

Yes, but they have poor latency, and packet loss due to hawks is a
major problem. But an RFC 1149 network is plausible, even if not
viable in most situations.

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


Re: Please help if you can!

2012-12-26 Thread Mitya Sirenef

On 12/26/2012 08:23 PM, Chris Angelico wrote:

On Thu, Dec 27, 2012 at 12:17 PM, Mitya Sirenef  wrote:

I have to agree - I saw that howto as well and it occurred to me
that if we have to delete blank lines manually we might
as well use postal pigeons with tiny little papyrus scrolls -
at least those don't insert blank lines automatically!

Yes, but they have poor latency, and packet loss due to hawks is a
major problem. But an RFC 1149 network is plausible, even if not
viable in most situations.

ChrisA


I don't know, I played starcraft II by pigeon-net and it
worked just fine. Yes, latency is quite bad but it gives
you more time to think about strategy...

 -m

--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

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


Re: How to get time.strptime()?

2012-12-26 Thread Gnarlodious
Nick Cash wrote:

> I was able to work around this by simply importing _strptime myself at server 
> startup time.

THANK YOU! That fixed it, I simply put 

import _strptime

in my *.wsgi script. It feels like a kludgy solution, but it works.

I should also mention that I had a similar problem with the "threading" module 
that I fixed in the same way. This problem occurred inside of sqlite3 because 
evidently threadlocking has gone standard as of Py 3.3.x

This is problem that has unduly vexed me. When you start learning Python they 
don't tell you about these sharp edges. Someone needs to explain.

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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-26 Thread Rick Johnson
On Wednesday, December 26, 2012 2:29:13 AM UTC-6, Steven D'Aprano wrote:
> [snip]

I won't reply to your last post on a line-by-line basis because i feel we are 
straying from my general point: which is that we should NEVER re-interpret 
existing words (in an illogical manner) whilst transforming them into specific 
disciplines.

My specific point is that the English word "variable" is unambiguous and 
transforms smoothly to an abstract idea of an identifier referencing an object, 
and also, that the reference is "variable" (or has the ability to change). The 
word "variable" is a WONDERFUL example of transforming existing words into 
specific esoteric disciplines.

Alternatively, you want to argue that the word "attribute" is a better choice 
NOT because "variable" cannot transform to a programming context, BUT because 
you want use "variable" to reference some "attribute" of an 
object...*smile*..., oh i see.

But seriously, 
What is an "attribute" anyway?


#Define: Attribute #

# Noun: A quality or feature regarded as a characteristic  #
# or inherent part of someone or something.#


Interesting. And what about "inherent"?


# Define: Inherent #

# Adjective: Existing in something as a permanent, #
# essential, or characteristic attribute   #


Ahh... so an "attribute" is attached to an entity (okay, we could easily 
transform the word "entity" to a memory object, but) ...that is "permanent" AND 
"essential"! OPPS! Here is where your logic breaks down. Variables COULD NOT be 
considered permanent: neither existentially or referentially. Please 
re-consider this illogical transformation of the word "attribute".

[Slightly Tangential Meanderings Ahead...]
Okay, now that we've ironed-out the wrinkles in our "variable" and we see how 
"variable" traverses perfectly into a computing context, i want to talk about 
how some of our most /ingrained/ syntax is NOT correct! Specifically i want to 
talk about "class" and "def".

The words "class" and "def" are HORRIBLE choices for defining "classes" (oops, 
i should say objects, but it seems the brainwashing has run it's coarse!) and 
"methods/functions". I know, I know, your gut reaction is to _cling_  to what 
is familiar -- and these words have become FAR TOO familiar to all of us -- but 
again, let's do some introspection of these words we "THINK" we understand.

Ask yourself. What /is/ a class?

A class is nothing more than a textual template defined by the programmer for 
which Python reads and creates OBJECTS in memory. If instead of "class" we used 
the word "object" to define a (wait for it...) "object" we would NOT ONLY be 
consistent and logical, we would inject more intuitiveness into our language. 
Can you imagine the confusion a new programmer would feel when told that he 
must use "classes" to create "objects" when the only definition of classes he 
understands is "classrooms" and "classifications".

So the correct syntax follows:

OBJECT Car(object):
def __init__(self)
#

same goes for methods/functions

FUNCTION foo(args):
... pass

Of course i would be open to "obj" and "func" respectively (well maybe). But i 
favor the following syntax for even more intuitive consistency:

define object Car(...):
define function foo(...):

That is a work of logical fine art!. However a new problem arises: "function" 
an illogical choice. "Procedure" would be the obvious choice, however, old 
school CS majors YET AGAIN redefined a word into illogic oblivion.

Some people think Python's syntax is great, and i must confess i am one of 
those people, but even after all of Guido's whining about the failures of ABC's 
syntax he then went on to commit the same crimes[1]

[1] to a far less degree of course :-).
-- 
http://mail.python.org/mailman/listinfo/python-list


Query re language for running videos on TV

2012-12-26 Thread mjperreau
I am new to raspberry pi and am looking at coming up with a program with a
GUI menu for selecting saved videos onto HD TV.
Can someone point me in the right direction please.
 
Thanks
 
MikePee   [user name]
Ph: 06 8453931 Cell: 027 2438085
mjperr...@gmail.com
Skype: mike.perreau
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get time.strptime()?

2012-12-26 Thread Steven D'Aprano
On Wed, 26 Dec 2012 19:09:51 -0800, Gnarlodious wrote:

> This is problem that has unduly vexed me. When you start learning Python
> they don't tell you about these sharp edges.


"Hi, I've just started learning Python today, and I have a question. How 
do I print a list?"

"Before I answer that question, let me explain to you how to fix a 
problem with time.strptime that only occurs when running under mod_wsgi. 
Now, I know that you're still struggling with print, haven't even got to 
importing modules yet, have no idea what strptime is, and that 99.99% of 
Python programmers will never use mod_wsgi in their life, but if we don't 
tell you about this right now, in five years time you will complain that 
nobody told you about the sharp edges when you started..."

*wink*

A serious question: when should somebody have told you about this sharp 
edge, and who should have been responsible to do so?



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


Re: How to get time.strptime()?

2012-12-26 Thread Roy Smith
In article <0e36e143-5103-4b4b-aaa9-b7b1b7686...@googlegroups.com>,
 Gnarlodious  wrote:

> This is problem that has unduly vexed me. When you start learning Python they 
> don't tell you about these sharp edges. Someone needs to explain.

The same thing happens when you're born.  You spend your entire life 
figuring out the sharp edges.  And then you die.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding the name of a function while defining it

2012-12-26 Thread Tim Roberts
Abhas Bhattacharya  wrote:
>
>While I am defining a function, how can I access the name (separately as
>string as well as object) of the function without explicitly naming 
>it(hard-coding the name)?
>For eg. I am writing like:
>def abc():
>#how do i access the function abc here without hard-coding the name?

Why?  Of what value would that be?

Note that I'm not merely being obstructionist here.  What you're asking
here is not something that a Python programmer would normally ask.  The
compiled code in a function, for example, exists as an object without a
name.  That unnamed object can be bound to one or more function names, but
the code doesn't know that.  Example:

def one():
print( "Here's one" )

two = one

That creates one function object, bound to two names.  What name would you
expect to grab inside the function?

Even more obscure:

two = lamba : "one"
one = two

Which one of these is the "name" of the function?
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-26 Thread Steven D'Aprano
On Wed, 26 Dec 2012 20:07:53 -0800, Rick Johnson wrote:

> My specific point is that the English word "variable" is unambiguous

I'm sorry, do you mean "variable" the noun, or "variable" the adjective?

If you mean the adjective, do you mean something which naturally changes, 
in the sense that the amount of rainfall is naturally variable, or a 
collection of independent things which individually are constant but 
collectively vary, such as the heights of children in a classroom are 
variable?

If you mean the noun, do you mean a factor which is likely to vary, as in 
"the weather is one variable to consider", or a quantity that is capable 
of taking on a multitude of values, or a symbol which represents a fixed 
but unknown quantity?

If you're going to claim that an English word is unambiguous, you 
probably should choose an example with only one meaning.


> we should NEVER
> re-interpret existing words (in an illogical manner) whilst transforming
> them into specific disciplines.

I'm sorry yet again, did you mean "discipline" in the sense of 
punishment, "discipline" in the sense of learning by instruction and 
exercise, "discipline" in the sense of submission to authority, or 
"discipline" in the sense of a field of study?


I am sorry[1] to ignore the main points of your post in favour of 
attacking the very foundations of your argument, but if you build your 
argument on counter-factuals (assumptions about English language which 
are not, in fact, true) then even if your reasoning is utterly logical in 
every step, the conclusion is still dubious.



[1] Ah who am I kidding?

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


Re: How to get time.strptime()?

2012-12-26 Thread Mitya Sirenef

On 12/26/2012 10:09 PM, Gnarlodious wrote:
This is problem that has unduly vexed me. When you start learning 
Python they don't tell you about these sharp edges. Someone needs to 
explain. -- Gnarlie 


In fact, if there were no bugs, there would be no need to explain nor to 
pick the

right time / place for explanations. Why doesn't Python warn that it's not
100% perfect? Are people just supposed to "know" this, magically?

--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

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


Re: I am facing an issue while decoding json string using json.loads

2012-12-26 Thread Tim Roberts
sajuptpm  wrote:
>
>I am facing an issue while decoding json string using json.loads(jstring).
>Its working, if i do json.dumps(eval(jstring)) before json.loads(jstring).
>I could not figure out the issue. I want to avoide use of "eval" here.

The problem is that your string contains two instances of an escaped right
bracket  \]  .  That's not one of the characters you're allowed to escape
in JSON.  The rules are very strict.  There are only 8 allowed escape
codes, plus the \u construct.

Note that you cannot just replace \] with ], because your string also
contains one instance of \\] .

Who is doing the JSON encoding?  It appears to be doing it incorrectly.
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get time.strptime()?

2012-12-26 Thread Chris Angelico
On Thu, Dec 27, 2012 at 4:06 PM, Mitya Sirenef  wrote:
> On 12/26/2012 10:09 PM, Gnarlodious wrote:
>>
>> This is problem that has unduly vexed me. When you start learning Python
>> they don't tell you about these sharp edges. Someone needs to explain. --
>> Gnarlie
>
>
> In fact, if there were no bugs, there would be no need to explain nor to
> pick the
> right time / place for explanations. Why doesn't Python warn that it's not
> 100% perfect? Are people just supposed to "know" this, magically?

People are supposed to know that Python is not 100% perfect because
there's no such thing as a 100% perfect language. The problem here is
that Python doesn't have any magical way to deal with messy imports in
multiple threads; the solution is to sort out the import before the
multiple threads get going (meaning that when each thread attempts the
import, it's resolved trivially by simply binding the existing module
to a new name).

Threads are fairly messy in the best of times. The only thing I could
imagine Python doing here would be a brutal global lock - as soon as
one thread starts any import, all other threads get locked out of
execution (or at least of other imports). And I'm not sure that'd
solve everything - plus it brings the risk that one thread can stall
the entire system with a failed or faulty import. If you can think of
of any way to improve this, I'm sure python-ideas will happily discuss
it.

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


Re: Finding the name of a function while defining it

2012-12-26 Thread Chris Angelico
On Thu, Dec 27, 2012 at 3:52 PM, Tim Roberts  wrote:
> The
> compiled code in a function, for example, exists as an object without a
> name.  That unnamed object can be bound to one or more function names, but
> the code doesn't know that.  Example:
>
> def one():
> print( "Here's one" )
>
> two = one
>
> That creates one function object, bound to two names.  What name would you
> expect to grab inside the function?

Presumably 'one'.

> Even more obscure:
>
> two = lamba : "one"
> one = two
>
> Which one of these is the "name" of the function?

I would say ''. Whatever method is used to get the function's
name, I would expect it to match the __name__ attribute of the
function (which is a peer to __code__, but I don't think the
function's code *is* the function).

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


Re: Query re language for running videos on TV

2012-12-26 Thread Chris Angelico
On Thu, Dec 27, 2012 at 3:35 PM, mjperreau  wrote:
> I am new to raspberry pi and am looking at coming up with a program with a
> GUI menu for selecting saved videos onto HD TV.
>
> Can someone point me in the right direction please…

Huh, sounds like the Yosemite Project, one of the first non-trivial
programs I wrote in Python.

https://github.com/Rosuav/Yosemite

It uses a web browser as its UI, but this is what we use for running
our TV. Feel free to borrow ideas and/or code from it (code's all
available under the BSD 2-clause license).

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


Re: How to get time.strptime()?

2012-12-26 Thread Gnarlodious
Chris Angelico wrote:
 
> The problem here is that Python
> doesn't have any magical way to deal with messy imports in
> multiple threads
But couldn't Py 3.3.1 at least raise an error mentioning threading as a 
possible cause? Because "No module named  _strptime" is pretty cryptic.

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


Re: How to get time.strptime()?

2012-12-26 Thread Ben Finney
Mitya Sirenef  writes:

> Why doesn't Python warn that it's not 100% perfect? Are people just
> supposed to "know" this, magically?

+1 QotW

-- 
 \   “[T]he speed of response of the internet will re-introduce us |
  `\to that from which our political systems have separated us for |
_o__)so long, the consequences of our own actions.” —Douglas Adams |
Ben Finney

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


Re: Please help if you can!

2012-12-26 Thread alex23
On 27 Dec, 11:00, Chris Angelico  wrote:
> One of the regulars on the list has posted a run-down of how to post
> from Google Groups without annoying everyone, and among other things,
> it recommends manually deleting all the blank lines.

I'm still posting via Groups and am not seeing my posts come through
with blank lines or weird formatting.

However, I _am_ regularly (every goddamn day, thanks for nothing,
Google) telling the new UI to bugger off and reverting to the old,
sane, thread-on-one-page-not-three UI. I think the issues are with the
new UI, which just further reinforces my belief that Google are trying
to just kill Groups dead.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Twisted-Python] Twisted 12.3.0 released

2012-12-26 Thread Glyph
On Dec 26, 2012, at 5:21 AM, Thomas Hervé  wrote:

> On behalf of Twisted Matrix Laboratories, I am pleased to announce, in
> extremis, the release of Twisted 12.3.

Thanks for managing another great release, Thomas!!

> 161 tickets are closed by this release, with the following highlights:
> 
> * Support for local parallel testing in trial

This doesn't make the feature sound quite as exciting as it is :).  For those 
of you who didn't know this was coming - as of Twisted 12.3.0, you can run 
'trial -j 16 ...' if you have 16 cores and finally make use of all those idle 
cores during Twisted-based development.

-glyph

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


Re: [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-26 Thread Ranting Rick
On Dec 26, 11:02 pm, Steven D'Aprano  wrote:
> On Wed, 26 Dec 2012 20:07:53 -0800, Rick Johnson wrote:
> > My specific point is that the English word "variable" is unambiguous
>
> I'm sorry, do you mean "variable" the noun, or "variable" the adjective?
> [snip: sliding down the rabbit hole of a polysemantic nightmare...]

And now my dear friend you arrive at the horrible truth. The truth
that your language is defeating you. The truth that you dare not speak
because of the fear of unfamiliarity. You don't like that feeling, you
fear it, you prefer the warmth of clinging to a warm fuzzy something,
EVEN IF that something is a abomination.

So what do we do?

Well the obvious answer is to scrap the whole thing and start over.
Start with a system of word creation that is intelligently expandable
instead of what we have now which is a haphazard at best. Stringing
bits of Greek with bits of Latin may increase your social status at
the local chess club, but you are only injecting more garbage into the
system. The whole architecture is flawed. It's flawed in greek, it's
flawed in latin, and it's flawed in Python. You cannot create gold
from lead: "Polish a turd, it's still a turd!"

But short of re-inventing the English language ( heck, you people
won't even _admit_ to the inconsistencies in Python syntax, much less
commit to _repairing_ them!) the flaws in natural language cannot be
used as an excuse to inject illogic/inconsistency/multiplicity at your
whim. We should hold ourselves to a higher standard.

Every keyword, syntactical structure, style, etc, etc, should be based
on logical foundations; not adolescent fads or propagating more
idiotic cultural traditions. You piss and moan about language X and
how asinine the language is, them you go and repeat the same stupid
mistakes simply because you don't want to "rock the boat"?!

"""Well, urm, i don't particularly like "aspect x" about this
language, but most programmers have internalized the practice and i
don't want to confuse them with intelligent design, consistency or
logic, so i'll just propagate more of this stupidity so everyone can
feel warm and fuzzy."""

Well thanks Mr. language designer, now we'll be corralling braces for
another fifty FREAKING YEARS!

PS: Grow a pair!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding the name of a function while defining it

2012-12-26 Thread Abhas Bhattacharya
On Wednesday, 26 December 2012 08:41:28 UTC+5:30, Roy Smith  wrote:
> In article ,
> 
>  Abhas Bhattacharya  wrote:
> 
> 
> 
> > While I am defining a function, how can I access the name (separately as 
> 
> > string as well as object) of the function without explicitly naming 
> 
> > it(hard-coding the name)?
> 
> > For eg. I am writing like:
> 
> > def abc():
> 
> > #how do i access the function abc here without hard-coding the name?
> 
> 
> 
> Do you need it at compile-time, or is it good enough to have the name a 
> 
> run-time?  Assuming the latter, then I'm thinking the traceback module 
> 
> is your friend.  Call traceback.extract_stack() and pull off the last 
> 
> frame in the stack.  The function name will be in there.
> 
> 
> 
> There may be a cleaner way, but that's what I've done in the past.
> 
> 
> 
> I've only ever wanted the name.  If you need the actual function object, 
> 
> I suppose you might eval() the name, or something like that.

I need it compile-time.
During run-time, I can always use: function_name.__name__ (although that's kind 
of lame because it returns "function_name"). But if the function itself 
contains print(__name__) and I call the function, it returns __main__ (yes, 
__main__ itself, not the string "__main__") (which is the calling function).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding the name of a function while defining it

2012-12-26 Thread Abhas Bhattacharya
On Thursday, 27 December 2012 11:14:36 UTC+5:30, Chris Angelico  wrote:
> On Thu, Dec 27, 2012 at 3:52 PM, Tim Roberts  wrote:
> 
> > The
> 
> > compiled code in a function, for example, exists as an object without a
> 
> > name.  That unnamed object can be bound to one or more function names, but
> 
> > the code doesn't know that.  Example:
> 
> >
> 
> > def one():
> 
> > print( "Here's one" )
> 
> >
> 
> > two = one
> 
> >
> 
> > That creates one function object, bound to two names.  What name would you
> 
> > expect to grab inside the function?
> 
> 
> 
> Presumably 'one'.
> 
> 
> 
> > Even more obscure:
> 
> >
> 
> > two = lamba : "one"
> 
> > one = two
> 
> >
> 
> > Which one of these is the "name" of the function?
> 
> 
> 
> I would say ''. Whatever method is used to get the function's
> 
> name, I would expect it to match the __name__ attribute of the
> 
> function (which is a peer to __code__, but I don't think the
> 
> function's code *is* the function).
> 
> 
> 
> ChrisA

If i call one() and two() respectively, i would like to see "one" and "two".
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding the name of a function while defining it

2012-12-26 Thread Chris Angelico
On Thu, Dec 27, 2012 at 6:26 PM, Abhas Bhattacharya
 wrote:
> During run-time, I can always use: function_name.__name__ (although that's 
> kind of lame because it returns "function_name"). But if the function itself 
> contains print(__name__) and I call the function, it returns __main__ (yes, 
> __main__ itself, not the string "__main__") (which is the calling function).

That's because __name__ looks for that attribute on the module (aka
"global variable"), not the function. When you run your Python script
as an application, the module is called __main__.

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


Re: Finding the name of a function while defining it

2012-12-26 Thread Abhas Bhattacharya
On Thursday, 27 December 2012 10:22:15 UTC+5:30, Tim Roberts  wrote:
> Abhas Bhattacharya  wrote:
> 
> >
> 
> >While I am defining a function, how can I access the name (separately as
> 
> >string as well as object) of the function without explicitly naming 
> 
> >it(hard-coding the name)?
> 
> >For eg. I am writing like:
> 
> >def abc():
> 
> >#how do i access the function abc here without hard-coding the name?
> 
> 
> 
> Why?  Of what value would that be?
> 
> 
> 
> Note that I'm not merely being obstructionist here.  What you're asking
> 
> here is not something that a Python programmer would normally ask.  The
> 
> compiled code in a function, for example, exists as an object without a
> 
> name.  That unnamed object can be bound to one or more function names, but
> 
> the code doesn't know that.  Example:
> 
> 
> 
> def one():
> 
> print( "Here's one" )
> 
> 
> 
> two = one
> 
> 
> 
> That creates one function object, bound to two names.  What name would you
> 
> expect to grab inside the function?
> 
> 
> 
> Even more obscure:
> 
> 
> 
> two = lamba : "one"
> 
> one = two
> 
> 
> 
> Which one of these is the "name" of the function?
> 
> -- 
> 
> Tim Roberts, t...@probo.com
> 
> Providenza & Boekelheide, Inc.

It is of quite value to me.
Because I have this situation:
I have used a dictionary with "function_name":value pair in the top of the 
code. Now when some function is called, I need to print the value assigned to 
its name in the dictionary (the functions are defined after the dictionary). 
Now there is only one bad way-around for me: I need to hard-code the name in 
the function like this:
def function_name():
print(dict_name.get("function_name"))
but ofcourse it is a bad thing to do because I have a lot of this type of  
functions. It would be better if I can can use the same code for all of them, 
because they are all essentially doing the same thing.

Now, for your questions:
If i call one() and two() respectively, i would like to see "one" and "two".
I dont have much knowledge of lambda functions, neither am i going to use them, 
so that's something I cant answer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding the name of a function while defining it

2012-12-26 Thread Abhas Bhattacharya
On Thursday, 27 December 2012 13:18:19 UTC+5:30, Chris Angelico  wrote:
> On Thu, Dec 27, 2012 at 6:26 PM, Abhas Bhattacharya
> 
>  wrote:
> 
> > During run-time, I can always use: function_name.__name__ (although that's 
> > kind of lame because it returns "function_name"). But if the function 
> > itself contains print(__name__) and I call the function, it returns 
> > __main__ (yes, __main__ itself, not the string "__main__") (which is the 
> > calling function).
> 
> 
> 
> That's because __name__ looks for that attribute on the module (aka
> 
> "global variable"), not the function. When you run your Python script
> 
> as an application, the module is called __main__.
> 
> 
> 
> ChrisA

Ok, that sheds some light on why it acts like that, but how can i use it the 
way I want (which i already told)?
-- 
http://mail.python.org/mailman/listinfo/python-list