Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

2013-09-20 Thread William Bryant
On Friday, September 20, 2013 11:09:03 AM UTC+12, Ian wrote:
> On Thu, Sep 19, 2013 at 1:22 PM, William Bryant  wrote:
> 
> > It was the other functions above it. Thanks. but I tried to do the while
> 
> > loop - I don't think I did it right, I am novice in python and I am 13 years
> 
> > old.
> 
> 
> 
> It should be structured like this:
> 
> 
> 
> while True:
> 
> answer = input("Enter yes/no:")
> 
> if answer in ('y', 'yes', 'new list'):
> 
> do_yes_stuff()
> 
> break
> 
> elif answer in ('n', 'no', 'close'):
> 
> do_no_stuff()
> 
> break
> 
> else:
> 
> print("Please enter y or n.")
> 
> 
> 
> If they answer 'yes' or 'no', then the break statement breaks out of
> 
> the while loop.  Otherwise the while loop continues from the top and
> 
> asks them again.

Thanks a lot! I have one more question, is there any way I can make my program 
work on android tablets and ipads? Because I'd like to use it in school because 
we are learning statistics and we are allowed our devices in school.


'''**'''
#* Name:Mode-Median-Mean Calculator   *#
#**#
#* Purpose: To calculate the mode, median and mean of a list of numbers   *#
#*  and the mode of a list of strings because that is what we are *#
#*  learning in math atm in school :P *#
#**#
#* Author:  William Bryant*#
#**#
#* Created: 11/09/2013*#
#**#
#* Copyright:   (c) William 2013  *#
#**#
#* Licence: IDK :3*#
'''**'''



#-#   ~~Import things I am using~~   #-#

# |
#|
#   \/

import time
import itertools



#-#~~Variables that I am using, including the list.~~#-#

# |
#|
#   \/

List = []
NumberOfXItems = []

#-#   ~~Functions that I am using.~~ #-#

# |
#|
#   \/

def HMNs():
global TheStr, user_inputHMNs, List_input, List
user_inputHMNs = input("You picked string. This program cannot calculate 
the mean or median, but it can calculate the mode. :D  How many strings are you 
using in your list? (Can not be a decimal number)  \nEnter:  ")
if user_inputHMNs == "restart":
NOS()
time.sleep(1.5)
TheStr = int(user_inputHMNs)
for i in range(TheStr):
List_input = input("Enter your strings. (One in each input field):  \n")
if List_input == "restart":
NOS()
List.append(List_input)

print("\nThis
 is the amount of strings you are using in your list:", user_inputHMNs)
print("and this is how much space you have left in your list for 
strings:", int(user_inputHMNs) - len(List), 
"\n\n")
print("Your list -> ", List)
print("(0 is the first number in your list)\n")
for i in range(len(List)):
print("number " + str(i) + ": " + str(List[i]))
print("\n*Mode*:", mode())
print("*Median*:",  "There is no median for a list of strings - Only 
mode")
print("*Mean*:","There is no mean for a list of strings - Only 
mode")
if int(user_inputHMNs) - len(List) == 0:
init()


def HMNn():
global TheNum, user_inputHMNn, List_input, List
user_inputHMNn = input("You picked number. :D How many numbers are you 
using in your list? (Can not be a decimal number) \nEnter:  ")
if user_inputHMNn == "restart":
NOS()
time.sleep(1.5)
TheNum = int(user_inputHMNn)
for i in range(TheNum):
List_input = input("Enter your numbers. (One in each input field):  \n")
List_input = int(List_input)
if List_input == "restart":
NOS()
List.append(List_input)

print("\nThis
 is the amount of numbers you are using in your list:", user_inputHMNn)
print("and this is how much space you have left in your list for 
numbers:", int(user_inputHMNn) - len(List), 
"\n#

ANN: RPQueue 0.21

2013-09-20 Thread Josiah Carlson
Hello everyone,

For those of you who didn't know, if you are interested in a Redis-backed
time and/or fifo-queue with priorities, retries, etc., to be used with
Python, one exists and is mature: it's called RPQueue, and it seeks to
simplify your life of task execution. The recent changelog entries are
below my signature.

The package has been around for two years next month, and does exactly what
you expect it to do - no more, no less.

You can find the package at:
https://github.com/josiahcarlson/rpqueue/
https://pypi.python.org/pypi/rpqueue

Please CC me on any replies if you have any questions or comments.

Thank you,
 - Josiah

#--- 0.21

[changed] where available, rpqueue will now use Lua to move delayed tasks
from
the time-based priority queue to fifo queues. This should reduce
overhead
in all cases, and should drastically improve performance for those that
use large numbers of delayed tasks.
[changed] the version number is now PEP 386/440 compliant.
[added] this changelog that will document updates/changes/improvements in an
easily referenced location.
[fixed] thanks to https://github.com/dmaust , rpqueue added a missing
'redis'
requirement.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tryign to send mail via a python script by using the local MTA

2013-09-20 Thread Robert Kern

On 2013-09-20 04:56, Jake Angulo wrote:

Up Robert Kern's reply!

I was waiting for smtplib  to be
mentioned... finally!  Instead people simply answer philosophically.  I dont
want to judge whether OP is a troll or not - but i found a lot of arrogant
replies here.  I have also worked on an antispam project before, and see through
the intents of the OP, but I do not pretend to be a moralist. I was hoping we
would strictly discuss code or software architecture here, not morality. Simple
question, simple answer pls, in the interest of the Python list.


Please don't valorize my message. I did neither Nikos nor the group any favors. 
I can only plead dizziness from the whooshing of Tim's sarcasm flying over 
Nikos' head.


--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: Missing py2exe, needed 4 a gcode generator to engrave text in fancy ttf fonts in steel

2013-09-20 Thread Chris Angelico
On Fri, Sep 20, 2013 at 3:14 PM, Gene Heskett  wrote:
> Can someone take a look at
>
> 
>
> Then this is what I get:
> gene@coyote:~/src/F-Engrave-1.22_src$ python py2exe_setup.py
> Traceback (most recent call last):
>   File "py2exe_setup.py", line 4, in 
> import py2exe
> ImportError: No module named py2exe
>
> And tell me how to fix this so it runs on an older linux box?

The page you link to doesn't mention py2exe anywhere. Where did you
get that you need to run that command?

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


What minimum should a person know before saying "I know Python"

2013-09-20 Thread Aseem Bansal
I started Python 4 months ago. Largely self-study with use of Python 
documentation, stackoverflow and google. I was thinking what is the minimum 
that I must know before I can say that I know Python?

I come from a C background which is comparatively smaller. But as Python is 
comparatively much larger what minimum should I know?

Just a general question not for a specific purpose. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tryign to send mail via a python script by using the local MTA

2013-09-20 Thread feedthetroll
Hi Jake!

Am Freitag, 20. September 2013 05:56:57 UTC+2 schrieb Jake Angulo:
> ...
> I was waiting for smtplib to be mentioned... finally!  Instead people simply
> answer philosophically.  I dont want to judge whether OP is a troll or not -
As you do not seem to know the histrory of this topic I will try to summarize 
(you can find the plethora of posts in the archive):
* Nikos tried to send mails using smtplib via gmail
* gmail did not allow him to use arbitrary FROM adresses (whatever FROM-header 
he used, gmail changed it to the e-mail of his account). evil, evil gmail ;-)
* He got many, many hints not to send via gmail but use his own MTA
* Nikos configured sendmail to relay mail VIA GMAIL (unfortunately that did not 
change anything)
* while using arbitrary things to find the reason (when you browse the archive 
you will learn, that nikos does not read postings or docs but uses some sort of 
artistic or random or just chaotic "trial and error" to solve his problems)
* ... he found some other headers he wants to falsify
* the only reference to python is, that he wants to use his python-cgi-scripts 
to change the mailheaders AFTER the mail left his relaying MTA and even after 
the mail arrives in the inbox of the recipient (received-by-headers, 
IP-Adresses, ...). The hints to read some docs about TCP/IP, SMTP, ... he 
ignores as he has to do see 
http://www.politicsforum.org/images/flame_warriors/flame_62.php (the original 
by mreed is not reachable today)

hth 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread rusi
On Friday, September 20, 2013 3:28:00 PM UTC+5:30, Aseem Bansal wrote:
> I started Python 4 months ago. Largely self-study with use of Python 
> documentation, stackoverflow and google. I was thinking what is the minimum 
> that I must know before I can say that I know Python?
> 
> 
> 
> I come from a C background which is comparatively smaller. But as Python is 
> comparatively much larger what minimum should I know?
> 
> 
> 
> Just a general question not for a specific purpose.

Stroustrup says he is still learning C++ and I know kids who have no qualms 
saying they know programming language L (for various values of L) after hardly 
an hour or two of mostly advertising and pep-talk exposure.
So without knowing what you mean my 'knowing' I am not going to try answering 
q-1

I am just curious about q-2 -- C is small compared to python -- whats your 
measure for that?

BTW 20 years ago I wrote about why C is very hard to learn and teach
In these intervening years some things have changed, some have not

See
http://blog.languager.org/2013/02/c-in-education-and-software-engineering.html#relevate
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Tim Chase
On 2013-09-20 02:58, Aseem Bansal wrote:
> I started Python 4 months ago. Largely self-study with use of
> Python documentation, stackoverflow and google. I was thinking what
> is the minimum that I must know before I can say that I know Python?

It's a fuzzy line.  A good while back, there was a thread regarding
Python interview questions:

http://www.mail-archive.com/[email protected]/msg168971.html

to which I replied with a pretty large list.  The idea was not to
ensure that people knew everything on it, but as a way to take stock
of somebody means by "I know Python", which can mean anything from "I
wrote _Hello World_ in Python once" to "I'm Guido/Raymond/Effbot".

Along with the "Basics" section of that email, I'd expect a reasonable
understanding of commonly-used libraries offered out of the box (at
least a breadth of what is there, even if you haven't used them
much).

Most of the "history" items in that list are somewhat moot unless you
have to support older Python (I still have some 2.4 installs that
don't let me use the "with" statement or sqlite by default).

-tkc




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


Making it a MultiThread!

2013-09-20 Thread stas poritskiy
Hello All!

I have a general question, 
i was posting here earlier while trying to troubleshoot a few things while 
developing an application, i was able to hit all of my goals, and make things 
work! Thank you all who contributed to my research, and again, sorry for poor 
formatting of the threads, i am slowly learning;)

I am working on integration of multiple GUI (Tkinter) elements, such a progress 
bar, label update, etc, and throughout my research i discovered that i need to 
have Threading modules used to distribute the calls for GUI update and 
processing of my main App.

My Application is broken into multiple Classes(modules), and i wanted to hear 
your thought on the best practices to implement the Threading model.

I was thinking to create a new py-module, and reference all other modules/class 
to it, and create thread.start() objects, that would execute the GUI part, 
other will handle GUI Updates, and other - will be doing the processing.

Please share some of your thought on this approach, or maybe you may suggest a 
more effective way.
thanks !
-- 
https://mail.python.org/mailman/listinfo/python-list


I want to print entry and exit message for functions , i have bunch of such function . How can i do it in decorator.

2013-09-20 Thread bab mis
def fun:
print "entry"
.
.
print "exit"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

2013-09-20 Thread William Ray Wing
On Sep 20, 2013, at 3:01 AM, William Bryant  wrote:

[byte]

> 
> Thanks a lot! I have one more question, is there any way I can make my 
> program work on android tablets and ipads? Because I'd like to use it in 
> school because we are learning statistics and we are allowed our devices in 
> school.
> 
> 

[byte]

> 
> Thanks again - Will 
> 

Python doesn't come pre-installed on tablets the way it does on most computers. 
 However, there are low-cost commercial python apps for tablets.  The one I'm 
most familiar with is Pythonista, available for the iPad in the Apple App 
store.  Last time I looked it was $6.95.

Bill

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


Re: Missing py2exe, needed 4 a gcode generator to engrave text in fancy ttf fonts in steel

2013-09-20 Thread Gene Heskett
On Friday 20 September 2013 08:48:44 Chris Angelico did opine:

> On Fri, Sep 20, 2013 at 3:14 PM, Gene Heskett  wrote:
> > Can someone take a look at
> > 
> >  > e>
> > 
> > Then this is what I get:
> > gene@coyote:~/src/F-Engrave-1.22_src$ python py2exe_setup.py
> > 
> > Traceback (most recent call last):
> >   File "py2exe_setup.py", line 4, in 
> >   
> > import py2exe
> > 
> > ImportError: No module named py2exe
> > 
> > And tell me how to fix this so it runs on an older linux box?
> 
> The page you link to doesn't mention py2exe anywhere. Where did you
> get that you need to run that command?
> 
> ChrisA

>From the example command to run the setup, a short script:
gene@coyote:~/src/F-Engrave-1.22_src$ cat py2exe_setup.py
#run this from the command line: python py2exe_setup.py py2exe

from distutils.core import setup
import py2exe

setup(
options = {"py2exe": {"compressed": 1, "optimize": 0, } },
zipfile = None,
console=[{"script":"f-engrave-122.py","icon_resources":
[(0,"fengrave.ico"),(0,"fengrave.ico")]}]

As shown on the setup page accompanying this

, lower left of 
the list at the top of the page.  Supposedly by using the src, I can build 
it with TTF support, which is missing from the file offered in the right 
most python only column.  All the other checks and tests on the setup page 
work, and all the other dependencies appear to have been met.

The setup file itself I find, shouldn't have been included in the zip 
without a README.linux that says to skip it.

The shipped fengrave-122.py actually runs but is not finding any fonts.  
There s/b quite a few installed since I have used TrueTypeTracer 
extensively before.  But I may have my machines mixed, and the computer 
running the milling machine is probably where I did all that.

I haven't had my morning coffee yet, so I am ill equipt to do more ATM.

Thank you.





Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
My web page:  should be up!

Seize the day, put no trust in the morrow!
-- Quintus Horatius Flaccus (Horace)
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
 law-abiding citizens.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I want to print entry and exit message for functions , i have bunch of such function . How can i do it in decorator.

2013-09-20 Thread Peter Otten
bab mis wrote:

> def fun:
> print "entry"
> .
> .
> print "exit"


>>> def log(f):
... def g(*args, **kw):
... print "enter", f.__name__
... try:
... return f(*args, **kw)
... finally:
... print "exit", f.__name__
... return g
... 
>>> @log
... def divide(a, b):
... return a / b
... 
>>> divide(4, 2)
enter divide
exit divide
2
>>> divide(4, 0)
enter divide
exit divide
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 5, in g
  File "", line 3, in divide
ZeroDivisionError: integer division or modulo by zero


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


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Robert Kern

On 2013-09-20 12:43, rusi wrote:

On Friday, September 20, 2013 3:28:00 PM UTC+5:30, Aseem Bansal wrote:

I started Python 4 months ago. Largely self-study with use of Python 
documentation, stackoverflow and google. I was thinking what is the minimum 
that I must know before I can say that I know Python?

I come from a C background which is comparatively smaller. But as Python is 
comparatively much larger what minimum should I know?

Just a general question not for a specific purpose.


Stroustrup says he is still learning C++ and I know kids who have no qualms 
saying they know programming language L (for various values of L) after hardly 
an hour or two of mostly advertising and pep-talk exposure.
So without knowing what you mean my 'knowing' I am not going to try answering 
q-1


I think that's his actual question: "What do *you* mean by 'I know Python'?" At 
what point in your Python career did you feel comfortable claiming that?


--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

2013-09-20 Thread Duncan Booth
William Bryant  wrote:

> Thanks a lot! I have one more question, is there any way I can make my
> program work on android tablets and ipads? Because I'd like to use it
> in school because we are learning statistics and we are allowed our
> devices in school. 
> 

You can install SL4A on Android and that should let you run your script on 
an Android tablet. You may want to modify the script to work with the 
android UI, or it might be enough just to run it in a terminal window.

I don't believe there is an ipad equivalent, but so long as you have a 
network connection, another option to consider (that would work on both 
android and ipad) would be to run the script on a server somewhere and 
connect to it through a web browser. Have a look at https://c9.io as that 
gives you a full development environment that can be accessed through a web 
browser: I don't know how well it works on a tablet but it would be worth 
trying.


-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Chris Angelico
On Fri, Sep 20, 2013 at 7:58 PM, Aseem Bansal  wrote:
> I started Python 4 months ago. Largely self-study with use of Python 
> documentation, stackoverflow and google. I was thinking what is the minimum 
> that I must know before I can say that I know Python?
>
> I come from a C background which is comparatively smaller. But as Python is 
> comparatively much larger what minimum should I know?
>
> Just a general question not for a specific purpose.

Interesting.

Everything's relative. I would say that I "know Python" at the point
where I am comfortable using it to solve problems, as opposed to using
it to learn Python. That is to say, when you choose Python (above
bash, or above some other language, or whatever) because it will take
you less time to achieve a goal in Python than in any other language,
when it's the goal that's important.

I'd also add, though it's somewhat tangential to the first, that
"knowing Python" also requires knowing when/where Python is a good
choice of language. I like to be able to make one-sentence summaries
of the form "X is a good choice when you want to...":

* Python: put something together NOW, with no boilerplate
* Pike: run a server that reloads code without dropping connections
* C: implement a high level language (or a module for one)
* PHP: gouge your eyes out with a rusty fork, but aren't allowed to on work time
* Haskell: code functionally rather than imperatively (I'm not
familiar with a broad range of functional languages; someone who is
would be distinguishing them from each other)
* bash: execute a series of commands, with minimal processing in between
* Lua: embed a tiny and secure scripting language in an application
* JavaScript/ECMAScript: ditto, but less tiny
* Brainf*: gouge your eyes out with a rusty fork, but aren't allowed to use PHP

Etcetera. Familiarity with a language requires knowing both how to use
it and when to use it.

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


lambda - strange behavior

2013-09-20 Thread Kasper Guldmann
I was playing around with lambda functions, but I cannot seem to fully grasp
them. I was running the script below in Python 2.7.5, and it doesn't do what
I want it to. Are lambda functions really supposed to work that way. How do
I make it work as I intend?

f = []
for n in range(5):
f.append( lambda x: x*n )

assert( f[4](2) == 8 )
assert( f[3](3) == 9 )
assert( f[2](2) == 4 )
assert( f[1](8) == 8 )
assert( f[0](2) == 0 )

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


Antispam measures circumventing

2013-09-20 Thread Jugurtha Hadjar


Hello,

# I posted this on the tutor list, but my message wasn't displayed


I shared some assembly code (microcontrollers) and I had a comment wit 
my e-mail address for contact purposes.


Supposing my name is John Doe and the e-mail is [email protected], my 
e-mail was written like this:


[email protected]'

With a note saying to remove the capital letters.

Now, I wrote this :

for character in my_string:
... if (character == character.upper()) and (character !='@') and 
(character != '.'):

... my_string = my_string.replace(character,'')


And the end result was [email protected].

Is there a better way to do that ? Without using regular expressions 
(Looked *really* ugly and it doesn't really make sense, unlike the few 
lines I've written, which are obvious even to a beginner like me).


I obviously don't like SPAM, but I just thought "If I were a spammer, 
how would I go about it".


Eventually, some algorithm of detecting the 
johndoehotmailcom must exist.



Also, what would in your opinion make it *harder* for a non-human to 
retrieve the original e-mail address? Maybe a function with no inverse 
function ? Generating an image that can't be converted back to text, etc..


If this is off-topic, you can just answer the "what is a better way to 
do that" part.


Thanks,



--
~Jugurtha Hadjar,

--
~Jugurtha Hadjar,
--
https://mail.python.org/mailman/listinfo/python-list


Re: Antispam measures circumventing

2013-09-20 Thread Vlastimil Brom
2013/9/20 Jugurtha Hadjar :
> Hello,
> # I posted this on the tutor list, but my message wasn't displayed
> I shared some assembly code (microcontrollers) and I had a comment wit my
> e-mail address for contact purposes.
> Supposing my name is John Doe and the e-mail is [email protected], my
> e-mail was written like this:
> [email protected]'
> With a note saying to remove the capital letters.
> Now, I wrote this :
> for character in my_string:
> ... if (character == character.upper()) and (character !='@') and
> (character != '.'):
> ... my_string = my_string.replace(character,'')
> And the end result was [email protected].
> Is there a better way to do that ? Without using regular expressions (Looked
> *really* ugly and it doesn't really make sense, unlike the few lines I've
> written, which are obvious even to a beginner like me).
> I obviously don't like SPAM, but I just thought "If I were a spammer, how
> would I go about it".
> Eventually, some algorithm of detecting the johndoehotmailcom
> must exist.
> retrieve the original e-mail address? Maybe a function with no inverse
> function ? Generating an image that can't be converted back to text, etc..
> If this is off-topic, you can just answer the "what is a better way to do
> that" part.
>
> Thanks,
> --
> ~Jugurtha Hadjar,
> --
> https://mail.python.org/mailman/listinfo/python-list


Hi,
is the regex really that bad for such simple replacement?

>>> re.sub(r"[A-Z]", "", "[email protected]")
'[email protected]'

Alternatively, you can use a check with the string method  isupper():
>>> "".join(char for char in "[email protected]" if 
>>> not char.isupper())
'[email protected]'

or using a special form of str.translate()
>>> "[email protected]".translate(None, 
>>> "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
'[email protected]'

which is the same like:
>>> import string
>>> "[email protected]".translate(None, 
>>> string.ascii_uppercase)
'[email protected]'

Another possibility would be to utilise ord(...)
>>> "".join(char for char in "[email protected]" if 
>>> ord(char) not in range(65, 91))
'[email protected]'
>>>

Well, maybe there are other possibilities, these above are listed
roughly in the order of my personal preference. Of course, others may
differ...

hth,
   vbr
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lambda - strange behavior

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 1:21 AM, Kasper Guldmann  wrote:
> f = []
> for n in range(5):
> f.append( lambda x: x*n )

You're leaving n as a free variable here. The lambda function will
happily look to an enclosing scope, so this doesn't work. But there is
a neat trick you can do:

f = []
for n in range(5):
f.append( lambda x,n=n: x*n )

You declare n as a second parameter, with a default value of the
current n. The two n's are technically completely separate, and one of
them is bound within the lambda.

BTW, any time you have a loop appending to a list, see if you can make
it a comprehension instead:

f = [lambda x,n=n: x*n for n in range(5)]

Often reads better, may execute better too.

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


Re: Antispam measures circumventing

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 1:04 AM, Jugurtha Hadjar
 wrote:
> Supposing my name is John Doe and the e-mail is [email protected], my
> e-mail was written like this:
>
> [email protected]'
>
> With a note saying to remove the capital letters.
>
> Now, I wrote this :
>
> for character in my_string:
> ... if (character == character.upper()) and (character !='@') and
> (character != '.'):
> ... my_string = my_string.replace(character,'')
>
>
> And the end result was [email protected].
>
> Is there a better way to do that ?

Instead of matching the ones that are the same as their uppercase
version, why not instead keep the ones that are the same as their
lowercase?

>>> email = '[email protected]'
>>> ''.join(filter(lambda x: x==x.lower(),email))
'[email protected]'

This could be a neat introduction to a functional style of code, if
you haven't already met it; use of filter and lambda expressions can
make for some beautifully expressive code.

> Also, what would in your opinion make it *harder* for a non-human
> to retrieve the original e-mail address? Maybe a function with no
> inverse function ? Generating an image that can't be converted back
> to text, etc..

Ah, now you're getting into the realm of CAPTCHAs. I'll be quite frank
with you: Don't bother. Many MANY experts are already looking into it
- with various levels of success. Spammers are getting better and
better at harvesting addresses and solving CAPTCHAs, and your legit
users aren't getting that benefit, so you make it harder for the
humans while still possible for the bots. (And some CAPTCHAs are
solved by simply farming the jobs off to actual human beings (in
China, I think I heard) for a pittance each. There's fundamentally no
way to prevent that.) So your options are:

1) Call on someone else's code. Search the internet for ways of
concealing email addresses, pick one that isn't too much hassle to
legit users, and use it. I've seen quite a few that put the email
address in an image, one way or another; they tend to be a bit
annoying, but some aren't too bad.

2) Give up on protecting your address, and protect your inbox instead.
Get some good spam filtering, and let 'em send it all at you. I run a
local mail server for a few domains, and even with the filter set
conservatively enough to all but eliminate false positives, we see
only a handful of false negatives (according to my logs, 182 emails
reported as spam this week, across all domains and all accounts - most
accounts see <10 a week, a couple of them see maybe 20-30). And again,
you can call on someone else to do the work for you - sending all your
mail to gmail lets you take advantage of their filtering, for
instance.

But hey. If you want to play around with text processing, Python's a
good choice for it!

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


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread rusi
On Friday, September 20, 2013 7:09:13 PM UTC+5:30, Robert Kern wrote:
> On 2013-09-20 12:43, rusi wrote:
> > Stroustrup says he is still learning C++ and I know kids who have no qualms 
> > saying they know programming language L (for various values of L) after 
> > hardly an hour or two of mostly advertising and pep-talk exposure.
> 
> > So without knowing what you mean my 'knowing' I am not going to try 
> > answering q-1
> 
> 
> I think that's his actual question: "What do *you* mean by 'I know Python'?" 
> At what point in your Python career did you feel comfortable claiming that?

Hmm... Now you are putting me in a spot :-)
Too many aspects to this to give a reasonably short answer :-)
I'll try and collect my thoughts in due course...

What I meant to say to the OP:
Knowing a language can mean widely different things:
1. to crack interviews
2. as a junior programmer
3. as a tech-lead
4. for bug-fixing/maintaining others' code

A big difference between 1 and 2 is the value of obfuscated/ting code
For 1 knowing trick questions/answers is a big win; for 2 more likely a loss.
Also for 1 a big breath-first knowledge is required; for 2 its ok to know a 
subset well and be able to use it with good taste.

For 3 right emotions are more important than details -- to look at a 
significant piece of code and be accurate in exclaiming "Wonderful/Blechhh"

4 is really an important and much neglected mindset. Ive talked about it here

http://blog.languager.org/2010/02/service-and-product-mindsets.html

Ok... So trying to say (a little!) in answer to your (Robert's) question though 
tangentially.

Ive spent 20 years in a university.  Most of what goes on there may be called 
gaming.
- The best students are not the one's who know or love to know most but who 
successfully game the system
- The best teachers are not those who teach best but who are one-up on the 
students' gaming habits and tendencies
- The best administrators are those who are cleverest at using academic 
(sounding) jargon to make lucrative institutions

Sounds cynical?  Well most of the students are not the 'best students' above 
and so its more important to gauge where (s)he is coming from, where going etc 
and to answer appropriately rather than giving to-the-point answers when the 
student may be too bewildered to ask exact/precise questions.

Basically instruct him just enough on how to game the system so that he clears 
the course but not so much he loses his soul!
-- 
https://mail.python.org/mailman/listinfo/python-list


dynamic function parameters for **kwargs

2013-09-20 Thread bab mis
Hi ,
I have a function as below:

def func(**kwargs):
...
...




args="a='b',c='d'"

i want to call func(args) so that my function call will take a var as an 
parameter.

it fails with an error "typeError: fun() takes exactly 0 arguments (1 given)" 

. Is there any other way to get the same.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lambda - strange behavior

2013-09-20 Thread Rotwang

On 20/09/2013 16:21, Kasper Guldmann wrote:

I was playing around with lambda functions, but I cannot seem to fully grasp
them. I was running the script below in Python 2.7.5, and it doesn't do what
I want it to. Are lambda functions really supposed to work that way. How do
I make it work as I intend?

f = []
for n in range(5):
 f.append( lambda x: x*n )

assert( f[4](2) == 8 )
assert( f[3](3) == 9 )
assert( f[2](2) == 4 )
assert( f[1](8) == 8 )
assert( f[0](2) == 0 )


This is a common gotcha. In the function "lambda x: x*n" n is a global 
variable, which means that when the function is called it searches 
globals() for the current value of n, which is 4 (since that was its 
value when the for loop ended). There are several ways to define 
functions that depend on the values bound to names at creation time, 
like you're trying to do. One is to use the fact that default function 
arguments are evaluated when the function is created. So this will work:


f = []
for n in range(5):
f.append(lambda x, n = n: x*n)


Another is to use the fact that arguments passed in function calls are 
evaluated when the function is called. That means that you can define a 
function which takes a parameter as an argument and returns a function 
which depends on that parameter to get the desired behaviour, like this:


f = []
for n in range(5):
f.append((lambda n: lambda x: x*n)(n))
--
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 2:28 AM, Aseem Bansal  wrote:
> I hope that cleared some confusion about what I wanted to ask. I wanted to 
> gauge myself to find if I am progressing or not.

Well, based on my definition, that's easy to answer. Have you solved
problems using Python? If you have a bunch of HTML pages and you need
to get some info out of all of them by COB today, do you think "I can
do that with Python", or do you think "I can do that with sed, awk,
grep, and five levels of pipe"? The tools you use for an urgent job
will be the ones you know.

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


Re: lambda - strange behavior

2013-09-20 Thread rusi
On Friday, September 20, 2013 8:51:20 PM UTC+5:30, Kasper Guldmann wrote:
> I was playing around with lambda functions, but I cannot seem to fully grasp
> them. I was running the script below in Python 2.7.5, and it doesn't do what
> I want it to. Are lambda functions really supposed to work that way. How do
> I make it work as I intend?
> 
> f = []
> for n in range(5):
> f.append( lambda x: x*n )
> 
> assert( f[4](2) == 8 )
> assert( f[3](3) == 9 )
> assert( f[2](2) == 4 )
> assert( f[1](8) == 8 )
> assert( f[0](2) == 0 )

You are not wrong in being surprised.  Here's the python rewritten in a more 
functional style

And then the same in haskell.

$ python3
Python 3.3.2+ (default, Jun 13 2013, 13:47:13) 
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> fl= [lambda x: x + n for n in range(5)]
>>> [f(1) for f in fl]
[5, 5, 5, 5, 5]
>>> 

---haskell-
$ ghci
GHCi, version 7.4.1: http://www.haskell.org/ghc/  :? for help

Prelude> let fl = [\x-> x+n | n <- [0..4]] 
Prelude> [f 1 | f <- fl]
[1,2,3,4,5]
Prelude> 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Aseem Bansal
By C being smaller than Python I did not mean the scope of C is lesser than 
Python. I simply meant that the standard libraries are less in number compared 
to Python.

By knowing Python I didn't imply an expert-level understanding. Minimum that so 
someone cannot say "Hey, you said you knew Python but you don't know 
anything.". Something on these lines. You can say for cracking interviews 
and/or as a junior programmar and/or as a fresher getting into industry.

I like to have test cases for my functions/scripts but that wasn't what I had 
in my mind.

Also I am learning Python because it is faster to make things with it. Not 
because it is going to get me any marks or anything.

@Tim Chase
That list helped. I was looking for something like that. Questions which I can 
try to answer and see where I stand.

I hope that cleared some confusion about what I wanted to ask. I wanted to 
gauge myself to find if I am progressing or not.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Antispam measures circumventing

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 2:23 AM, Jussi Piitulainen
 wrote:
> (Put .invalid at the end, maybe. But I wish spam was against the law,
> effectively.)

Against what law, exactly? In what jurisdiction will you seek to
charge spammers? And who will track them down?

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


Re: lambda - strange behavior

2013-09-20 Thread Jussi Piitulainen
Kasper Guldmann writes:

> I was playing around with lambda functions, but I cannot seem to
> fully grasp them. I was running the script below in Python 2.7.5,
> and it doesn't do what I want it to. Are lambda functions really
> supposed to work that way. How do I make it work as I intend?
> 
> f = []
> for n in range(5):
> f.append( lambda x: x*n )
> 
> assert( f[4](2) == 8 )
> assert( f[3](3) == 9 )
> assert( f[2](2) == 4 )
> assert( f[1](8) == 8 )
> assert( f[0](2) == 0 )

It's not the lambda, it's the for. All five functions share the one n,
whose value the for changes in each iteration so that the last value
remains in force after the loop.

There's a trick: f.append( lambda x, n=n: x*n ). Now the lambda gets
to remember the value of the n of the for as the default value of its
own local n.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Mark Janssen
> I started Python 4 months ago. Largely self-study with use of Python 
> documentation, stackoverflow and google. I was thinking what is the minimum 
> that I must know before I can say that I know Python?

Interesting.  I would say that you must know the keywords, how to make
a Class, how to write a loop.  That covers about 85% of it.
-- 
MarkJ
Tacoma, Washington
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Antispam measures circumventing

2013-09-20 Thread Jussi Piitulainen
Jugurtha Hadjar writes:

> Supposing my name is John Doe and the e-mail is [email protected],
> my e-mail was written like this:
> 
> [email protected]'
> 
> With a note saying to remove the capital letters.
> 
> Now, I wrote this :
> 
> for character in my_string:
> ... if (character == character.upper()) and (character !='@') and
> (character != '.'):
> ... my_string = my_string.replace(character,'')

That does a lot of needless work, but I'll suggest other things
instead of expanding on this remark.

First, there's character.isupper() that will replace your entire
condition.

Second, there's ''.join(c for c in my_string if not c.isupper()).

> And the end result was [email protected].
> 
> Is there a better way to do that ? Without using regular expressions
> (Looked *really* ugly and it doesn't really make sense, unlike the few
> lines I've written, which are obvious even to a beginner like me).

I don't see how you get to consider '[A-Z]' ugly. (Python doesn't seem
to have the named character classes like '[[:upper:]]' that would do
more than ASCII in some regexp systems. I only looked very briefly.)

Third, here's a way - try help(str.translate) and help(str.maketrans)
or python.org for some details:

 >>> from string import ascii_uppercase
 >>> 'Ooh, CamelCase!'.translate(str.maketrans('', '', ascii_uppercase))
 'oh, amelase!'

> I obviously don't like SPAM, but I just thought "If I were a spammer,
> how would I go about it".
> 
> Eventually, some algorithm of detecting the
> johndoehotmailcom must exist.
> 
> Also, what would in your opinion make it *harder* for a non-human to
> retrieve the original e-mail address? Maybe a function with no
> inverse function ? Generating an image that can't be converted back
> to text, etc..

Something meaningful: make it [email protected] with a note to
"remove the female deer" for [email protected], or "remove the drop
of golden sun" for "[email protected]". You may get a cease and
desist letter - much uglier than a simple regex - if you do literally
this, but you get the idea. I've seen people using "remove the animal"
or "remove the roman numeral".

(Put .invalid at the end, maybe. But I wish spam was against the law,
effectively.)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: dynamic function parameters for **kwargs

2013-09-20 Thread stas poritskiy
On Friday, September 20, 2013 10:51:46 AM UTC-5, bab mis wrote:
> Hi ,
> 
> I have a function as below:
> 
> 
> 
> def func(**kwargs):
> 
> ...
> 
> ...
> 
> 
> 
> 
> 
> 
> 
> 
> 
> args="a='b',c='d'"
> 
> 
> 
> i want to call func(args) so that my function call will take a var as an 
> parameter.
> 
> 
> 
> it fails with an error "typeError: fun() takes exactly 0 arguments (1 given)" 
> 
> 
> 
> . Is there any other way to get the same.

Hi, may be this will be useful to you:
http://simeonfranklin.com/blog/2012/jul/1/python-decorators-in-12-steps/

Go to Section 11 in the document.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Antispam measures circumventing

2013-09-20 Thread Jugurtha Hadjar

Chris, Vlastimil, great insights gentlemen! Thanks

Chris Angelico wrote:

>Instead of matching the ones that are the same as their uppercase
>version, why not instead keep the ones that are the same as their
>lowercase?


That's why I started off doing, and then lost track a bit. It didn't 
cross my mind that '.' and '@' are uncased characters and I'm a bit 
ashamed of not thinking about that before running the code


(i.e:

'.'.lower() gives False
'.'.upper() gives False

And the same for '@'. So unless you specifically "spare" them, they'll 
be whacked if you exclude upper case characters, or only include lower 
case characters).


>Ah, now you're getting into the realm of CAPTCHAs. I'll be quite frank
>with you: Don't bother. Many MANY experts are already looking into it

Yeah.. I thought of writing "My e-mail is my first name, dot, my last 
name at gmail dot com".


Some "riddling" can be viable to a certain extent. Or if your e-mail is 
[email protected]


ba, then 86, then rock, then star, at gm dot bu.

Or the e-mail can be generated dynamically calling a script that 
assembles pieces and displays it. This way, it can escape scrapers and 
all and will make it hard to manually harvest e-mails.. Which brings us 
to your next point about e-mail harvesters and that kind of labor (which 
is astounding !).





> email = '[email protected]'
> ''.join(filter(lambda x: x==x.lower(),email))
>'[email protected]'

Nice ! As well as Vlastimil's suggestions. The things I found on the net 
weren't that well written. There were *way* too many lines that made me 
think "No way. There's gotta be a better way".







--
~Jugurtha Hadjar,
--
https://mail.python.org/mailman/listinfo/python-list


Re: dynamic function parameters for **kwargs

2013-09-20 Thread Rotwang

On 20/09/2013 16:51, bab mis wrote:

Hi ,
I have a function as below:

def func(**kwargs):
 ...
 ...




args="a='b',c='d'"

i want to call func(args) so that my function call will take a var as an 
parameter.
it fails with an error "typeError: fun() takes exactly 0 arguments (1 given)"
. Is there any other way to get the same.


It fails because args is a string and func(args) is passing a single 
string as a positional argument to func, rather than passing the keyword 
arguments a and c. Not sure if I've understood your question, but


args = {'a': 'b', 'c': 'd'}
# or equivalently args = dict(a='b', c='d')
func(**args)

will work. If you need args to be a string like the one in your post 
then you could try


eval('func(%s)' % args)

or

func(**eval('dict(%s)' % args))

but that's only something that should be done if you trust the user who 
will decide what args is (since malicious code passed to eval() can do 
pretty much anything).

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


Re: Making it a MultiThread!

2013-09-20 Thread stas poritskiy
On Friday, September 20, 2013 7:56:16 AM UTC-5, stas poritskiy wrote:
> Hello All!
> 
> 
> 
> I have a general question, 
> 
> i was posting here earlier while trying to troubleshoot a few things while 
> developing an application, i was able to hit all of my goals, and make things 
> work! Thank you all who contributed to my research, and again, sorry for poor 
> formatting of the threads, i am slowly learning;)
> 
> 
> 
> I am working on integration of multiple GUI (Tkinter) elements, such a 
> progress bar, label update, etc, and throughout my research i discovered that 
> i need to have Threading modules used to distribute the calls for GUI update 
> and processing of my main App.
> 
> 
> 
> My Application is broken into multiple Classes(modules), and i wanted to hear 
> your thought on the best practices to implement the Threading model.
> 
> 
> 
> I was thinking to create a new py-module, and reference all other 
> modules/class to it, and create thread.start() objects, that would execute 
> the GUI part, other will handle GUI Updates, and other - will be doing the 
> processing.
> 
> 
> 
> Please share some of your thought on this approach, or maybe you may suggest 
> a more effective way.
> 
> thanks !

Here is some CODE that i wrote to present the working case.
my main program is split in multiple modules, but this structure should 
represent what i am trying to get.

module name: multiProcessLauncher.py

import multiprocessing
import gui

def main():
jobs = []
p = multiprocessing.Process(target=gui.basicGui)
jobs.append(p)
p.start()

if __name__ == '__main__':
main()
pass


Module Name: gui.py

from Tkinter import *
import tkMessageBox
import Tkinter
import multiProcessLauncher
import action

def basicGui():
g = action.Action()
print "GUI"
processor = multiProcessLauncher
name = processor.multiprocessing.current_process().name
print name, "starting"
print name, "exiting"
  
top = Tk()
button = Button(top, text = "Press Me", command = g.do_something)
button.pack()
top.mainloop()

def main():
pass
if __name__ == "__main__":
main()

Module Name: action.py

class Action(object):
def __init__(self):
self.text = "Running Action"
def do_something(self):
print self.text

i am trying to figure out how to make use of multiprocessing access the PRINT 
from the action.py using the GUI button. if you run the code and press the 
button, the console will read nothing, but as soon as you close the GUI, it 
spits out the text to console. I read about using Que, but i am not sure how to 
implement, could someone suggest how? thank you
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Antispam measures circumventing

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 2:23 AM, Jussi Piitulainen
 wrote:
> Something meaningful: make it [email protected] with a note to
> "remove the female deer" for [email protected], or "remove the drop
> of golden sun" for "[email protected]".

This method can be quite effective. In fact, of all the suggestions
made so far, I'd say these are a few of my favorite techniques...

*ducks the rotten tomatoes*

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


matplotlib question: OverflowError: Allocated too many blocks

2013-09-20 Thread Ray
hi,
i'm using matplotlib to generate chart from audio wave file, and I had a 
problem with it.

test code as:

from scipy.io import wavfile
import matplotlib.pyplot as plt
rate, x = wavfile.read('test2.wav')
plt.plot(x)
plt.savefig('test2.png')

the len of x= 19531840 (as len(x) )
matplotlib give exception: OverflowError: Allocated too many blocks

if I display it by:
plt.draw()
plt.show()

everything works fine. it seems I just can't save the output to a file. 
I know if I reduce the figsize would make it work. [aka 
plt.subplots(figsize=(5,2)) ] but this is not what I need. I need to generate 
the large chart. (depends on size of input file)

anyone know if there's another way to "save" big output file?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Jugurtha Hadjar
I think it is a philosophical question. It's like saying "I know maths", 
which is a ridiculous phrase I was surprised to hear, let alone 
surprised to hear often.


Can someone know everything there is to know about something ? I doubt 
it. The point, at least for me, isn't to know everything .. But the 
ability to find out.


I consider myself ignorant in almost everything, that's because I ask 
myself a lot of questions about a lot of things I ignore. The point is 
following up and looking things up so that you know them.


I knew many things I wasn't even aware existed. What this (constant 
questions) does is that it gives a lot of information that is networked 
(and you make a lot of connections between seemingly unrelated topics).


I'll give an example: I had a class in my second year in college about 
nuclear and atomic physics. There was a chapter about the Doppler 
effect. I was able to grasp it easily, because when I was a kid, it 
happened I took magazines in the bathroom to read, and I've read about it.


Having a déjà-vu impression in a lot of things and to be able to make 
analogies of concepts and principles has helped me tremendously. When I 
got into college and started programming PIC microcontrollers, having 
tinkered with Intel assembly language in high-school (disassembling 
executables and tinkering with them) was definitely a plus (Registers, 
operands, carry operations, hexadecimal, addresses).


When in the first year we started Pascal, I already did things in Delphi 
when I was in high-school. But then again, I also did tinker with C in 
middle-school (really basic stuff) and BASIC as a child.




Do I know Python ? No. I don't think I ever will. But I am confident I 
will be able to do what I cannot do right now, and the complexity of the 
things I will be able to do will increase, as will my ability to 
simplify complex things.



It's a converging exponential, as a capacitor charging. The goal is to 
minimized the time constant so you get at about 63.2% fast. The 
incremental 1%s will take years and I don't think you'll ever hit 100%, 
not even after decades. Sorry :)





--
~Jugurtha Hadjar,
--
https://mail.python.org/mailman/listinfo/python-list


building an online judge to evaluate Python programs

2013-09-20 Thread Jabba Laci
Hi,

In our school I have an introductory Python course. I have collected a
large list of exercises for the students and I would like them to be
able to test their solutions with an online judge (
http://en.wikipedia.org/wiki/Online_judge ). At the moment I have a
very simple web application that is similar to Project Euler: you
provide the ID of the exercise and the output of the program, and it
tells you if it's correct or not. However, it can only be used with
programs that produce an output (usually a short string or a number).

In the next step I would like to do the following. The user can upload
his/her script, and the system tests it with various inputs and tells
you if it's OK or not (like checkio.org for instance). How to get
started with this?

There are several questions:
* What is someone sends an infinite loop? There should be a time limit.
* What is someone sends a malicious code? The script should be run in a sandbox.

All tips are appreciated.

Thanks,

Laszlo
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Aseem Bansal
On Friday, September 20, 2013 10:04:32 PM UTC+5:30, Chris Angelico wrote:
> On Sat, Sep 21, 2013 at 2:28 AM, Aseem Bansal  wrote:
> > I hope that cleared some confusion about what I wanted to ask. I wanted to 
> > gauge myself to find if I am progressing or not.
> 
> Well, based on my definition, that's easy to answer. Have you solved
> problems using Python? If you have a bunch of HTML pages and you need
> to get some info out of all of them by COB today, do you think "I can
> do that with Python", or do you think "I can do that with sed, awk,
> grep, and five levels of pipe"? The tools you use for an urgent job
> will be the ones you know.
> 
> ChrisA

Yeah I have. I needed to get stats from the front page of a website. I wrote a 
script for that. I plotted the stats using matplotlib. I collected data 
manually and missed running the script one day so I took care of that problem 
using Python. Wrote a script that checked for internet connectivity and then 
ran the scripts that downloaded the stuff I needed and then placed this script 
in the Windows startup folder. 

That was a nice feeling. Because I can just customize that startup script if I 
ever wanted to change my computer's startup behaviour.

But that was pure luck that I had done the random example that you had chosen. 
It would be difficult to find my overall progress by the one thing.

I am currently unemployed so the sense of urgency isn't there normally. That's 
why I asked this question. But I got your point.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Aseem Bansal
I understand that being able to solve problems and knowing when to use 
something is the final measure of knowing something properly. 

But I wanted to find something quantitative that I can use to measure myself. 
Like the interview questions that Tim Chase posted.

Measuring myself based on the problems that I can think of is like a small 
child saying "I know that 1 + 1 = 2. So I know maths". That may be the toughest 
problem that he can think of. That isn't a correct evaluation of his math 
abilities. Similarly measuring myself on the basis of the problems that I can 
think of and solve doesn't actually measure anything.

I don't want to be living in a fool's paradise based on solving the problems I 
can solve. It is not being able to solve a problem that will make me realize my 
limits.

That's why I asked this question... I am kind of asking for advice.
-- 
https://mail.python.org/mailman/listinfo/python-list


pyGTK Help Needed Please

2013-09-20 Thread bingefeller
Hi folks,

I'm trying to run a program called Nicotine+ on my Mac which is running 10.8.5. 
Nicotine+ requires GTK2, pyGTK2 and Python to run. I believe I have all of 
these installed via Macports (please see here - http://pastebin.com/nwmrpp2Y )

When I try to run Nicotine+ I get this message:

'/Users/**/Downloads/nicotine+-1.2.16', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
 '/Library/Python/2.7/site-packages']
Exception: No module named pygtk


If I run Python and type import pygtk I get this message:

Traceback (most recent call last):
File "", line 1, in 
ImportError: No module named pygtk


can anyone help me please?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python GUI?

2013-09-20 Thread Metallicow
On Wednesday, September 11, 2013 3:55:59 PM UTC-5, Eamonn Rea wrote:
> There are a few known GUI toolkits out there, and the main ones from what I 
> can tell are:
> 
> 
> 
> Tkinter -- Simple to use, but limited
> 
> PyQT -- You have a GUI designer, so I'm not going to count that
> 
> PyGTK -- Gnome officially back this I think
> 
> wxPython -- Very nice, very professional, approved by Python creator, but 
> alas hard to get started with
> 
> 
> 
> So, what are your personal preferences and why? Why use X over Y?
> 
> 
> 
> I, personally, really like wxPython, but I also really like Tkinter. I've 
> messed with PyGTK, but I'd choose wxPython over it.
> 
> 
> 
> Have you got anything to say on what one I should be using(excluding PyQT 
> because it has a D&D designer >:( )? Is Tkinter really dead? Should I stick 
> with wxPython?
> 
> 
> 
> It's might be similar to the "What language to use" argument, or the "What 
> background to code on" argument(I prefer darker backgrounds xD Please don't 
> argue about this though!), in the sense that there is *no* answer, just 
> preference.
> 

I prefer wx over qt for these reasons.
Robin works for qt now. *Funny isn't it...*
Basically, To change qt(PySide) you need to pretty much need to be employed by 
qt, not the case with wx(is not a *For profit*, but you can donate.).
In my opinion, in the long run(foreseeing from this point forward)
wx will win, because anybody can create a popular fork. And if it is good 
enough, it might get accepted into the standard dist also.

As far as "mature", well, the previous statement shows that he can make money 
doing it also and enjoy doing what he does in his spare time. I believe Guido 
has the privilege of spending half of his time "At work and getting paid for 
it." on python.
And Project Phoenix(Py2/3) is still on the way. We'll revisit this question 
next year.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: building an online judge to evaluate Python programs

2013-09-20 Thread Aseem Bansal
>However, it can only be used with programs that produce an output

Just interested, what else are you thinking of checking?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: building an online judge to evaluate Python programs

2013-09-20 Thread Jabba Laci
Let's take this simple exercise:

"Write a function that receives a list and decides whether the list is
sorted or not."

Here the output of the function is either True or False, so I cannot
test it with my current method.

Laszlo

On Fri, Sep 20, 2013 at 7:57 PM, Aseem Bansal  wrote:
>>However, it can only be used with programs that produce an output
>
> Just interested, what else are you thinking of checking?
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Antispam measures circumventing

2013-09-20 Thread Joel Goldstick
On Fri, Sep 20, 2013 at 12:45 PM, Jugurtha Hadjar  wrote:

> Chris, Vlastimil, great insights gentlemen! Thanks
>
>
> Chris Angelico wrote:
>
> >Instead of matching the ones that are the same as their uppercase
> >version, why not instead keep the ones that are the same as their
> >lowercase?
>
>
> That's why I started off doing, and then lost track a bit. It didn't cross
> my mind that '.' and '@' are uncased characters and I'm a bit ashamed of
> not thinking about that before running the code
>
> (i.e:
>
> '.'.lower() gives False
> '.'.upper() gives False
>
> And the same for '@'. So unless you specifically "spare" them, they'll be
> whacked if you exclude upper case characters, or only include lower case
> characters).
>
>
> >Ah, now you're getting into the realm of CAPTCHAs. I'll be quite frank
> >with you: Don't bother. Many MANY experts are already looking into it
>
> Yeah.. I thought of writing "My e-mail is my first name, dot, my last name
> at gmail dot com".
>
> Some "riddling" can be viable to a certain extent. Or if your e-mail is
> [email protected]
>
> ba, then 86, then rock, then star, at gm dot bu.
>
> Or the e-mail can be generated dynamically calling a script that assembles
> pieces and displays it. This way, it can escape scrapers and all and will
> make it hard to manually harvest e-mails.. Which brings us to your next
> point about e-mail harvesters and that kind of labor (which is astounding
> !).
>
>
>
>
>
> > email = 'REMOVEMEjohn.doSPAMeSPAM@**REMOVEMEhotmail.com'
> > ''.join(filter(lambda x: x==x.lower(),email))
> >'[email protected]'
>
> Nice ! As well as Vlastimil's suggestions. The things I found on the net
> weren't that well written. There were *way* too many lines that made me
> think "No way. There's gotta be a better way".
>
>
>
>
>
>
>
> --
> ~Jugurtha Hadjar,
> --
> https://mail.python.org/**mailman/listinfo/python-list
>

Last year I was playing around with django forms and wrote some code that
required the user to add some numbers before the form was submitted. Here
is the article: http://www.joelgoldstick.com/blog/2012/sep/30/django-forms/

This isn't exactly what you are asking, but it does give you a change to
let someone send you mail without giving out your email address.

With the onslaught of social media stuff, it feels like sites like linked
in and anything that uses gmail want to get you to give away your email
address, and perhaps give access to everyone in your lists. So, I'm
suggesting its really a loosing battle.

-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: building an online judge to evaluate Python programs

2013-09-20 Thread John Gordon
In  Jabba Laci 
 writes:

> Let's take this simple exercise:

> "Write a function that receives a list and decides whether the list is
> sorted or not."

> Here the output of the function is either True or False, so I cannot
> test it with my current method.

Make a master input file and a master output file for each exercise.  If
the student program's output matches the master output when run from the
master input, then it is correct.

-- 
John Gordon   A is for Amy, who fell down the stairs
[email protected]  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: Python GUI?

2013-09-20 Thread Michael Torrie
On 09/20/2013 12:34 PM, Metallicow wrote:
> I prefer wx over qt for these reasons. Robin works for qt now. *Funny
> isn't it...* Basically, To change qt(PySide) you need to pretty much
> need to be employed by qt, not the case with wx(is not a *For
> profit*, but you can donate.). In my opinion, in the long
> run(foreseeing from this point forward) wx will win, because anybody
> can create a popular fork. And if it is good enough, it might get
> accepted into the standard dist also.

Qt is not a company. Qt is an open source project owned and sponsored by
Digia and also Nokia, though Nokia's participation will probably be
reduced now that Microsoft has bought Nokia.  Two years ago, at least,
lots of code commits came from outside Nokia.  Now, PySide was
originally a Nokia project when they owned Qt, and I know they did have
contributions from the community.  I don't see any evidence things have
changed.

Your logical reasoning is certainly faulty on one point, however. Why
would you claim wx is forkable but PySide (or even Qt) is not?

Both are completely open source and free software (as in LGPL).


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


Re: Python GUI?

2013-09-20 Thread Metallicow
Sorry about that, nokia is/was.
qt was developed(IIRC) for phones. Someone made money. And a lot of it.
wx is a more or less a "free" project.
I don't use a phone anymore. If I had a touch screen phone and was a developer, 
I still wouldn't use one. I have my many reasons why...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: building an online judge to evaluate Python programs

2013-09-20 Thread Jabba Laci
> That last seems to me to be the biggie.  Several times in the past few
> years, people in this mailing list have tried to build a safe sandbox.
> And each one was a big failure, for a hacker of sufficient interest.
> Some of them were spectacular failures.
>
> If you have to be safe from your user, Python may be the wrong language
> to give them.

Well, the course is about Python and I want to test Python scripts...

I've heard about "chroot jail" but I never used it. Wikipedia says:

"A chroot on Unix operating systems is an operation that changes the
apparent root directory for the current running process and its
children. A program that is run in such a modified environment cannot
name (and therefore normally not access) files outside the designated
directory tree. The term "chroot" may refer to the chroot(2) system
call or the chroot(8) wrapper program. The modified environment is
called a "chroot jail"."

I guess it could be used for sandboxing.

Laszlo
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: building an online judge to evaluate Python programs

2013-09-20 Thread John Gordon
In  Jabba Laci 
 writes:

> There are several questions:
> * What is someone sends an infinite loop? There should be a time limit.

You could run the judge as a background process, and kill it after ten
seconds if it hasn't finished.

> * What is someone sends a malicious code? The script should be run in a
> sandbox.

You could run the judge from its own account that doesn't have access to
anything else.  For extra security, make the judge program itself owned by
a separate account (but readable/executable by the judge account.)

I suppose you'd have to disable mail access from the judge account too.
Not sure how to easily do that.

-- 
John Gordon   A is for Amy, who fell down the stairs
[email protected]  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Iterate through a list of tuples for processing

2013-09-20 Thread Shyam Parimal Katti
I have a list of tuples where the number of rows in the list and the number
of columns in tuples of the list will not be constant. i.e.



list = [(a1,b1, …z1), (a2,b2, …, z2),…. ,(am,bm, … , zm )]. It can be
compared to the SQL results, as the number of columns change in the sql,
the number of columns change in the list of tuples as well.



I have to iterate through each element of each tuple in the list, perform
some checks on the value, convert it and return the modified values as a
new list of tuples.



i.e.

list_value = [(‘name1’, 1234, ‘address1’ ), (‘name2’, 5678, ‘address2’),
(‘name3’, 1011, ‘addre”ss3’)]



I need to access each value to check if the value contains a double quote
and enclose the string containing double quote with double quotes. The
transformation should return



list_value = [(‘name1’, 1234, ‘address1’ ), (‘name2’, 5678, ‘address2’),
(‘name3’, 1011, ‘”addre”ss3”’)]



The simplest approach for me would be to do this:



mod_val = [transform(row) for row in list_value]



def transform(row):

   mod_list=[]

   while index < len(row):

...if isinstance(row[index],basestring):

...   if '"' in row[index]:

...  mod_list.append('"'+row[index]+'"')

...else:

...   mod_list.append(row[index])

...index = index+1

... return mod_list





Is there a way to make the code concise using list comprehension?
-- 
https://mail.python.org/mailman/listinfo/python-list


Print statement not printing as it suppose to

2013-09-20 Thread Sam
hi everybody i am just starting to learn python, i was writing a simple i/o 
program but my print statement is acting weird. here is my code i want to know 
why it prints this way. thank you


car=int(input("Lamborghini tune-up:"))

rent=int(input('\nManhatan apartment: '))

gifts=int(input('\nRandom Gifts: '))

total=car+rent+gifts

print("\nThe total amount required is ", total )


OUTPUT

Lamborghini tune-up:1000

Manhatan apartment: 2300

Random Gifts: 234
('\nThe total amount required is ', 3534)



===> the problem is obviously on the last print statement that is supposed to 
print the outut
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Print statement not printing as it suppose to

2013-09-20 Thread Tim Delaney
On 21 September 2013 07:57, Sam  wrote:

> hi everybody i am just starting to learn python, i was writing a simple
> i/o program but my print statement is acting weird. here is my code i want
> to know why it prints this way. thank you
>
> print("\nThe total amount required is ", total )
>
>
> OUTPUT
>
> ('\nThe total amount required is ', 3534)
>
> ===> the problem is obviously on the last print statement that is supposed
> to print the outut
>

Check your version of Python. The output you have given says that you're
using a Python 2 version, but the print syntax you're using is for Python
3. Unfortunately, you've hit one of the edge cases where they produce
different output.

As a general rule, either use % formatting or format()to produce a single
string to print, rather than relying on print to output them correctly for
you (or using string concatenation). Since you're only just starting you
won't have got to them yet - the simplest way to to it is to just insert
the string representation of all parameters. The above done using %
formatting would be:

print("\nThe total amount required is  %s" % (total,))

which will produce the same output on both Python 2 and Python 3. Note the
double space before %s - that matches your print statement (there would be
soft-space inserted in your print statement, which is another reason not to
rely on print for anything other than single strings). If you didn't want
that extra space, it's easy to delete.

Tim Delaney
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Print statement not printing as it suppose to

2013-09-20 Thread Emiliano Carlos de Moraes Firmino
Remove both brackets in last line, You are creating a tuple in last
statement not making a function call.


2013/9/20 Sam 

> hi everybody i am just starting to learn python, i was writing a simple
> i/o program but my print statement is acting weird. here is my code i want
> to know why it prints this way. thank you
>
>
> car=int(input("Lamborghini tune-up:"))
>
> rent=int(input('\nManhatan apartment: '))
>
> gifts=int(input('\nRandom Gifts: '))
>
> total=car+rent+gifts
>
> print("\nThe total amount required is ", total )
>
>
> OUTPUT
>
> Lamborghini tune-up:1000
>
> Manhatan apartment: 2300
>
> Random Gifts: 234
> ('\nThe total amount required is ', 3534)
>
>
>
> ===> the problem is obviously on the last print statement that is supposed
> to print the outut
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Emiliano Carlos de Moraes Firmino
Desenvolvedor | PMT | INdT
Universitário | Engenharia da Computação | UEA
[email protected] | (92) 9196-3922
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Print statement not printing as it suppose to

2013-09-20 Thread John Gordon
In <[email protected]> Sam 
 writes:

> print("\nThe total amount required is ", total )

> OUTPUT

> ('\nThe total amount required is ', 3534)

In older versions of python (like the one you are using), 'print' is a
statement instead of a function.

In other words, it is used like this:

name = "Bob"
print "Hello ", name

Because there are parentheses around the text to be printed, your version
of python is interpreting it as a tuple.  Remove the parentheses and you
should be ok.

-- 
John Gordon   A is for Amy, who fell down the stairs
[email protected]  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Terry Reedy

On 9/20/2013 5:58 AM, Aseem Bansal wrote:

I started Python 4 months ago. Largely self-study with use of Python
documentation, stackoverflow and google. I was thinking what is the
minimum that I must know before I can say that I know Python?

I come from a C background which is comparatively smaller. But as
Python is comparatively much larger what minimum should I know?


The C stdlib may be smaller than the Python stdlib, but I do not think 
the language itself is much smaller. Python3 is a bit smaller than 
Python2 due to removals.


Python the language is defined in the Language Reference. So 'knowing 
Python' means knowing most of that. What I might leave out: the details 
of all the special method names; which bitwise operators do what; yield 
from (3.3+). From the library manual, I would include an overview of 
chapters 2 to 5. For instance, not memorize all the exceptions, but 
understand the hierarchy.


--
Terry Jan Reedy

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


Re: building an online judge to evaluate Python programs

2013-09-20 Thread Terry Reedy

On 9/20/2013 4:04 PM, Jabba Laci wrote:

That last seems to me to be the biggie.  Several times in the past few
years, people in this mailing list have tried to build a safe sandbox.
And each one was a big failure, for a hacker of sufficient interest.
Some of them were spectacular failures.

If you have to be safe from your user, Python may be the wrong language
to give them.


Well, the course is about Python and I want to test Python scripts...

I've heard about "chroot jail" but I never used it. Wikipedia says:

"A chroot on Unix operating systems is an operation that changes the
apparent root directory for the current running process and its
children. A program that is run in such a modified environment cannot
name (and therefore normally not access) files outside the designated
directory tree. The term "chroot" may refer to the chroot(2) system
call or the chroot(8) wrapper program. The modified environment is
called a "chroot jail"."

I guess it could be used for sandboxing.


Perhaps running in a virtual environment helps. 3.3 comes with venv, 
which I believe is a version of virtualenv or something.


--
Terry Jan Reedy

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


Re: building an online judge to evaluate Python programs

2013-09-20 Thread Jabba Laci
I just found Docker ( http://docs.docker.io/en/latest/faq/ ). It seems
sandboxing could be done with this easily.

Laszlo

On Fri, Sep 20, 2013 at 10:08 PM, John Gordon  wrote:
> In  Jabba Laci 
>  writes:
>
>> There are several questions:
>> * What is someone sends an infinite loop? There should be a time limit.
>
> You could run the judge as a background process, and kill it after ten
> seconds if it hasn't finished.
>
>> * What is someone sends a malicious code? The script should be run in a
>> sandbox.
>
> You could run the judge from its own account that doesn't have access to
> anything else.  For extra security, make the judge program itself owned by
> a separate account (but readable/executable by the judge account.)
>
> I suppose you'd have to disable mail access from the judge account too.
> Not sure how to easily do that.
>
> --
> John Gordon   A is for Amy, who fell down the stairs
> [email protected]  B is for Basil, assaulted by bears
> -- Edward Gorey, "The Gashlycrumb Tinies"
>
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: building an online judge to evaluate Python programs

2013-09-20 Thread Ned Batchelder

On 9/20/13 6:26 PM, Jabba Laci wrote:

I just found Docker ( http://docs.docker.io/en/latest/faq/ ). It seems
sandboxing could be done with this easily.


At edX, I wrote CodeJail (https://github.com/edx/codejail) to use 
AppArmor to run Python securely.


For grading Python programs, we use a unit-test like series of 
challenges.  The student writes problems as functions (or classes), and 
we execute them with unit tests (not literally unittest, but a similar 
idea).  We also tokenize the code to check for simple things like, did 
you use a while loop when the requirement was to write a recursive 
function.  The grading code is not open-source, unfortunately, because 
it is part of the MIT courseware.


--Ned.

Laszlo

On Fri, Sep 20, 2013 at 10:08 PM, John Gordon  wrote:

In  Jabba Laci 
 writes:


There are several questions:
* What is someone sends an infinite loop? There should be a time limit.

You could run the judge as a background process, and kill it after ten
seconds if it hasn't finished.


* What is someone sends a malicious code? The script should be run in a
sandbox.

You could run the judge from its own account that doesn't have access to
anything else.  For extra security, make the judge program itself owned by
a separate account (but readable/executable by the judge account.)

I suppose you'd have to disable mail access from the judge account too.
Not sure how to easily do that.

--
John Gordon   A is for Amy, who fell down the stairs
[email protected]  B is for Basil, assaulted by bears
 -- Edward Gorey, "The Gashlycrumb Tinies"

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


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


Re: Python GUI?

2013-09-20 Thread Michael Torrie
On 09/20/2013 01:58 PM, Metallicow wrote:
> Sorry about that, nokia is/was. qt was developed(IIRC) for phones.
> Someone made money. And a lot of it. wx is a more or less a "free"
> project. I don't use a phone anymore. If I had a touch screen phone
> and was a developer, I still wouldn't use one. I have my many reasons
> why...

Qt was first available back in 1995 from TrollTech, Inc.  Qt was always
about a good cross-platform UI toolkit that made it possible to develop
rich apps on Windows, Linux, and Mac.  Qt was one of the very first
modern GUI toolkits available on Linux.  I used KDE 1.0, which was based
on Qt back in 1998, long before cell phones with touch screens! In fact
I owe the KDE and Qt developers a debt of gratitude because KDE 1.0 was
really the first desktop that was usable to me as a Windows 95 refuge.
Moved to Linux and haven't looked back.

Qt only recently got touch stuff added, that make it work on phones and
tablets.  And the same touch stuff is going into GTK+, and I'm sure wx
will get it too soon, if they want to stay relevant.

And yes someone made money on Qt back in the day, as the company
TrollTech developed and marketed the toolkit for many years.  Back in
the 90s, a dispute over the open source licensing of the Qt source code
led to the creation of the Gnome project and desktop, using what became
known as the Gtk+ library.  Now, however, Qt is under the LGPL so it's
both free and open source in every way, and we are essentially reaping
the rewards of a very long and expensive development history, all for
free!  Whether it was generosity or desperation, it does not matter.

So I'm guessing you don't use Linux either, since people including Linus
Torvalds have become rich developing Linux.  Most linux development and
even governance is under the auspices of some for-profit companies.  Yet
it flourishes and has remained a free and open OS, thanks to Torvalds'
foresight to choose the GPL as the license for the kernel, which evens
the playing field and regulates the corporate influence.

Sounds to me like you've never used Qt in any of its versions.  I have
used Qt, GTK+, and wx, and they are all fine toolkits.  My current
preference is GTK+.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Iterate through a list of tuples for processing

2013-09-20 Thread Vlastimil Brom
2013/9/20 Shyam Parimal Katti :
> I have a list of tuples where the number of rows in the list and the number
> of columns in tuples of the list will not be constant. i.e.
>
>  ...> i.e.
>
> list_value = [(‘name1’, 1234, ‘address1’ ), (‘name2’, 5678, ‘address2’),
> (‘name3’, 1011, ‘addre”ss3’)]
>
> I need to access each value to check if the value contains a double quote
> and enclose the string containing double quote with double quotes. The
> transformation should return
>
> list_value = [(‘name1’, 1234, ‘address1’ ), (‘name2’, 5678, ‘address2’),
> (‘name3’, 1011, ‘”addre”ss3”’)]
>
>  ...>
>
>
> Is there a way to make the code concise using list comprehension?
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Hi,
would the following do, what you want?

>>> orig_list = [('name1', 1234, 'address1' ), ('name2', 5678, 'address2'), 
>>> ('name3', 1011, 'addre"ss3')]
>>> modif_list = [['"'+elem+'"' if isinstance(elem, basestring) and '"' in elem 
>>> else elem for elem in row] for row in orig_list]
>>> modif_list
[['name1', 1234, 'address1'], ['name2', 5678, 'address2'], ['name3',
1011, '"addre"ss3"']]
>>>

I guess, you don't mind changing the inner tuples to lists, but the
original structure could be retained as well:
>>> [tuple(['"'+elem+'"' if isinstance(elem, basestring) and '"' in elem else 
>>> elem for elem in row]) for row in orig_list]
[('name1', 1234, 'address1'), ('name2', 5678, 'address2'), ('name3',
1011, '"addre"ss3"')]
>>>

Of course, you have to decide, whether the readability/conciseness
suits your needs ...

hth,
   vbr
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: building an online judge to evaluate Python programs

2013-09-20 Thread Dave Angel
On 20/9/2013 13:28, Jabba Laci wrote:

> Hi,
>
> In our school I have an introductory Python course. I have collected a
> large list of exercises for the students and I would like them to be
> able to test their solutions with an online judge (
> http://en.wikipedia.org/wiki/Online_judge ). At the moment I have a
> very simple web application that is similar to Project Euler: you
> provide the ID of the exercise and the output of the program, and it
> tells you if it's correct or not. However, it can only be used with
> programs that produce an output (usually a short string or a number).
>
> In the next step I would like to do the following. The user can upload
> his/her script, and the system tests it with various inputs and tells
> you if it's OK or not (like checkio.org for instance). How to get
> started with this?
>
> There are several questions:
> * What is someone sends an infinite loop? There should be a time limit.
> * What is someone sends a malicious code? The script should be run in a 
> sandbox.
>

That last seems to me to be the biggie.  Several times in the past few
years, people in this mailing list have tried to build a safe sandbox.
And each one was a big failure, for a hacker of sufficient interest.
Some of them were spectacular failures.

If you have to be safe from your user, Python may be the wrong language
to give them.


-- 
DaveA

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


Re: Python GUI?

2013-09-20 Thread Robert Kern

On 2013-09-20 19:34, Metallicow wrote:


I prefer wx over qt for these reasons.
Robin works for qt now. *Funny isn't it...*


Lying about someone's employment is not very funny. Robin does not work for "Qt" 
or even Digia, the nearest thing to a corporate "owner" of Qt these days.


  https://www.enthought.com/company/team/devs/


Basically, To change qt(PySide) you need to pretty much need to be employed by 
qt,


This is emphatically incorrect, by your own example. Robin does indeed 
contribute to the PySide project. Both Qt and PySide are both open to and 
*driven by* contributions from the community.


  http://qt-project.org/contribute
  http://qt-project.org/wiki/PySideContributors

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: mutlifile inheritance problem

2013-09-20 Thread Peter Cacioppi
On Thursday, March 21, 2002 2:03:23 PM UTC-7, Marc wrote:
> I have classes defined in different files and would like to inherit
> from a class in file A.py for a class in file B.py but am running into
> problems.  I'm using Python 1.5.2 on Windows NT
> 
> Here's a specific example:
> 
> 
> file cbase01.py:
> 
> class CBase:
> 
> def __init__(self):
> self.cclass = None
> print "cbase"
> 
> class CImStream(CBase):
> 
> def __init(self):
> CBase.__init__(self)
> print "CImStream"
> 
> *
> in file wrappers_A01.py: 
> 
> import cbase01
> reload(cbase01)
> 
> class ImStream_SavedBitmaps(cbase01.CImStream):
> 
> def __init__(self):
> cbase.CImStream.__init__(self)
> print "SavedBitmaps"
> 
> **
> in file sequencer01.py
> 
> import cbase01# the offending lines, program works 
> reload(cbase01)   # if I comment these out.
> 
> class Sequencer:
> 
> def Append(self, item):
> pass
> 
> *
> in test02.py
> 
> import wrappers_A01
> reload(wrappers_A01)
> 
> import sequencer01
> reload(sequencer01)
> 
> x0 = wrappers_A01.ImStream_SavedBitmaps()
> ***
> 
> If I run test02 I get the traceback
> 
> Traceback (innermost last):
>   File "", line 1, in ?
>   File "D:\PythonCode\pna\eyeTracking\tests\test02.py", line 15, in ?
> x0 = wrappers_A01.ImStream_SavedBitmaps()
>   File "D:\PythonCode\pna\eyeTracking\tests\wrappers_A01.py", line 21,
> in __init__
> cbase.CImStream.__init__(self)
> TypeError: unbound method must be called with class instance 1st
> argument
> 
> 
> Any ideas what I am doing wrong?
> 
> Thanks,
> Marc

Yes my post has a mistake re: polymorphism. It seems self.__class__, whether 
called directly or indirectly, is always going to refer to the parent of the 
instance class. My code works only if there are no grandparents.


Bummer, but glad to learn something new.

It's too bad, I really lean on reload(). It appears to be incompatible with 
inheritance more than one level deep.

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


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 3:40 AM, Aseem Bansal  wrote:
> On Friday, September 20, 2013 10:04:32 PM UTC+5:30, Chris Angelico wrote:
>> On Sat, Sep 21, 2013 at 2:28 AM, Aseem Bansal  wrote:
>> > I hope that cleared some confusion about what I wanted to ask. I wanted to 
>> > gauge myself to find if I am progressing or not.
>>
>> Well, based on my definition, that's easy to answer. Have you solved
>> problems using Python? If you have a bunch of HTML pages and you need
>> to get some info out of all of them by COB today, do you think "I can
>> do that with Python", or do you think "I can do that with sed, awk,
>> grep, and five levels of pipe"? The tools you use for an urgent job
>> will be the ones you know.
>>
>> ChrisA
>
> Yeah I have...
> But that was pure luck that I had done the random example that you had 
> chosen. It would be difficult to find my overall progress by the one thing.
>
> I am currently unemployed so the sense of urgency isn't there normally. 
> That's why I asked this question. But I got your point.

It wasn't exactly a random example; it's an extremely common task
(maybe without the "must be done today" restriction), and one that
Python happens to do fairly well. :)

There was a time, back in the 1990s, when REXX was my primary
language. (We were exclusively an OS/2 shop at the time, so it was a
good choice.) If I needed to write a quick script, it would be in
REXX. If I needed to parse text, I'd use REXX. If I wanted a GUI app,
I'd write it in VX-REXX. Later on, when I needed to write Windows
code, I tended to use C++. It wasn't till the late 2000s that I
started using Python for those sorts of jobs - even though I'd met the
language back in the 90s - indicating that that's when I actually knew
the language.

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


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Roy Smith
In article ,
 Chris Angelico  wrote:

> On Sat, Sep 21, 2013 at 2:28 AM, Aseem Bansal  wrote:
> > I hope that cleared some confusion about what I wanted to ask. I wanted to 
> > gauge myself to find if I am progressing or not.
> 
> Well, based on my definition, that's easy to answer. Have you solved
> problems using Python? If you have a bunch of HTML pages and you need
> to get some info out of all of them by COB today, do you think "I can
> do that with Python", or do you think "I can do that with sed, awk,
> grep, and five levels of pipe"? The tools you use for an urgent job
> will be the ones you know.

The fact that you reach for traditional command-line tools to parse HTML 
should not be taken as evidence that you don't know Python.  It should 
be taken as evidence that you have a lot of tools in your quiver and 
know when to use the right one.

I started with Python in the 1.4 days.  I will reach for Python these 
days in preference to Perl, Tcl, C, C++, Java, or PHP for most things.  
But, for a lot of basic text processing, I can throw together a sed, 
awk, grep, sort, uniq, wc, tac, tail, etc pipeline faster than I can 
write a Python program to do the same thing.

Oh, and by the way, the python.org home page has

$ curl -s python.org | tr ' ' '\n' | grep ^href= | wc -l
 124

124 links on it.

You're still reading the BeautifulSoup docs :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Print statement not printing as it suppose to

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 7:57 AM, Sam  wrote:
> car=int(input("Lamborghini tune-up:"))
> print("\nThe total amount required is ", total )
> OUTPUT
> ('\nThe total amount required is ', 3534)

As others have said, this output indicates that you're running under a
Python 2.x interpreter. I strongly recommend you switch to running
under Python 3.x - do not take the simple advice that might make it
work in both, because you have other differences which will trip you
up. In Python 2, the input function is extremely dangerous and should
be avoided: it *evaluates* its argument. (If you really *want* to
evaluate something, you can call the eval() function explicitly. You
don't want it to be hidden behind the innocuously-named input().)
Download Python 3.3 (or later) and start using that; you'll find it's
by far the better interpreter - years of improvements on top of the
version you're using there.

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


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 12:31 PM, Roy Smith  wrote:
> In article ,
>  Chris Angelico  wrote:
>
>> On Sat, Sep 21, 2013 at 2:28 AM, Aseem Bansal  wrote:
>> > I hope that cleared some confusion about what I wanted to ask. I wanted to
>> > gauge myself to find if I am progressing or not.
>>
>> Well, based on my definition, that's easy to answer. Have you solved
>> problems using Python? If you have a bunch of HTML pages and you need
>> to get some info out of all of them by COB today, do you think "I can
>> do that with Python", or do you think "I can do that with sed, awk,
>> grep, and five levels of pipe"? The tools you use for an urgent job
>> will be the ones you know.
>
> The fact that you reach for traditional command-line tools to parse HTML
> should not be taken as evidence that you don't know Python.  It should
> be taken as evidence that you have a lot of tools in your quiver and
> know when to use the right one.
>
> I started with Python in the 1.4 days.  I will reach for Python these
> days in preference to Perl, Tcl, C, C++, Java, or PHP for most things.
> But, for a lot of basic text processing, I can throw together a sed,
> awk, grep, sort, uniq, wc, tac, tail, etc pipeline faster than I can
> write a Python program to do the same thing.

Oh, absolutely! I never said that sed/awk/grep was a bad way to do
things; my point is that, when there are dozens of viable solutions to
a problem and you have to solve that problem *now*, you are going to
reach for the one you know best. I use sed all the time (it's one of
the easiest ways to edit a root-owned file from a non-root shell
script - 'sudo sed -i').

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


Re: mutlifile inheritance problem

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 10:17 AM, Peter Cacioppi
 wrote:
> It's too bad, I really lean on reload(). It appears to be incompatible with 
> inheritance more than one level deep.

Python's really not designed for reload of this nature. You can easily
make a nasty mess of things. If you're working in the interactive
interpreter, it's probably easier to just run a stand-alone program
and restart it every time; if you're actually trying to have an
application that runs long-term and can reload code on the fly, you
may want to consider a language that explicitly supports that (such as
Pike).

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


Re: pyGTK Help Needed Please

2013-09-20 Thread Michael Torrie
On 09/20/2013 12:30 PM, [email protected] wrote:
> Hi folks,
> 
> I'm trying to run a program called Nicotine+ on my Mac which is running 
> 10.8.5. Nicotine+ requires GTK2, pyGTK2 and Python to run. I believe I have 
> all of these installed via Macports (please see here - 
> http://pastebin.com/nwmrpp2Y )
> 
> When I try to run Nicotine+ I get this message:
> 
> '/Users/**/Downloads/nicotine+-1.2.16', 
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', 
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', 
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', 
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
>  '/Library/Python/2.7/site-packages']
> Exception: No module named pygtk
> 
> 
> If I run Python and type import pygtk I get this message:
> 
> Traceback (most recent call last):
> File "", line 1, in 
> ImportError: No module named pygtk
> 
> 
> can anyone help me please?

You probably need to run the program using the version of Python that's
installed in MacPorts.  Your system python does not know anything about
MacPorts, so it obviously can't find pyGTK, since it's not in the system
library location.  I can't remember where MacPorts puts things, but
presumably you'd have to do edit the nicotine+-1.2.16 file and change
the first line to point to the MacPorts version of python.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Print statement not printing as it suppose to

2013-09-20 Thread Dave Angel
On 20/9/2013 17:57, Sam wrote:

>
> print("\nThe total amount required is ", total )
>
>
> ('\nThe total amount required is ', 3534)
>
> ===> the problem is obviously on the last print statement that is supposed to 
> print the outut

Others have pointed out the version discrepancy.  But I'll also ask what
you're learning Python from.  If you've got a tutorial or book that uses
Python 3.x, then forget 2.x and install 3.3

If you're learning it in a class, then the instructor should already
have told you what version to use.

It is possible to install both 2.7 and 3.3, but you probably don't need
the confusion while you're learning.

-- 
DaveA


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


Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

2013-09-20 Thread William Bryant
On Saturday, September 21, 2013 1:39:41 AM UTC+12, Duncan Booth wrote:
> William Bryant  wrote:
> 
> 
> 
> > Thanks a lot! I have one more question, is there any way I can make my
> 
> > program work on android tablets and ipads? Because I'd like to use it
> 
> > in school because we are learning statistics and we are allowed our
> 
> > devices in school. 
> 
> > 
> 
> 
> 
> You can install SL4A on Android and that should let you run your script on 
> 
> an Android tablet. You may want to modify the script to work with the 
> 
> android UI, or it might be enough just to run it in a terminal window.
> 
> 
> 
> I don't believe there is an ipad equivalent, but so long as you have a 
> 
> network connection, another option to consider (that would work on both 
> 
> android and ipad) would be to run the script on a server somewhere and 
> 
> connect to it through a web browser. Have a look at https://c9.io as that 
> 
> gives you a full development environment that can be accessed through a web 
> 
> browser: I don't know how well it works on a tablet but it would be worth 
> 
> trying.
> 
> 
> 
> 
> 
> -- 
> 
> Duncan Booth http://kupuguy.blogspot.com

Ok thanks for that, I know I said 1 more question but I just made the median 
function, could u tell me how I could finish it? I can't think of a way:

def median():
medlist = List
medlist.sort()
if len(List) % 2:
while len(list) > 2:
medlist.popleft()
medlist.popright()
if medlist[0] == medlist[1]:
themedian = medlist
elif medlist[0] != medlist[1]:
#make an if statment to figure out the median if the last 2 left 
are not the same. Eg [1, 2] the middle value is 1.5
pass
else:
while len(medlist) > 1:
medlist.popleft()
medlist.popright()
themedian = medlist
return themedian
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

2013-09-20 Thread William Bryant
On Saturday, September 21, 2013 1:39:41 AM UTC+12, Duncan Booth wrote:
> William Bryant  wrote:
> 
> 
> 
> > Thanks a lot! I have one more question, is there any way I can make my
> 
> > program work on android tablets and ipads? Because I'd like to use it
> 
> > in school because we are learning statistics and we are allowed our
> 
> > devices in school. 
> 
> > 
> 
> 
> 
> You can install SL4A on Android and that should let you run your script on 
> 
> an Android tablet. You may want to modify the script to work with the 
> 
> android UI, or it might be enough just to run it in a terminal window.
> 
> 
> 
> I don't believe there is an ipad equivalent, but so long as you have a 
> 
> network connection, another option to consider (that would work on both 
> 
> android and ipad) would be to run the script on a server somewhere and 
> 
> connect to it through a web browser. Have a look at https://c9.io as that 
> 
> gives you a full development environment that can be accessed through a web 
> 
> browser: I don't know how well it works on a tablet but it would be worth 
> 
> trying.
> 
> 
> 
> 
> 
> -- 
> 
> Duncan Booth http://kupuguy.blogspot.com

Ok thanks for that, I know I said one more question, but could you pleasse help 
me here:

def median():
medlist = List
medlist.sort()
if len(medlist) % 2:
while len(medlist) > 2:
medlist.popleft()
medlist.popright()
if medlist[0] == medlist[1]:
themedian = medlist
elif medlist[0] != medlist[1]:
#make an if statment to figure out the median if the last 2 left 
are not the same. Eg [1, 2] the middle value is 1.5
pass
else:
while len(medlist) > 1:
medlist.popleft()
medlist.popright()
themedian = medlist
return themedian

It says out of range and i don't know how I am going to make an if statment to 
figure out the median if the last 2 left are not the same. Eg [1, 2] the middle 
value is 1.5. Thanks - I am 13 year old beginner in python and i am trying to 
finish the tutorial on code academy and read the docs. :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying "I know Python"

2013-09-20 Thread Gene Heskett
On Saturday 21 September 2013 01:34:50 Chris Angelico did opine:

> On Sat, Sep 21, 2013 at 3:40 AM, Aseem Bansal  
wrote:
> > On Friday, September 20, 2013 10:04:32 PM UTC+5:30, Chris Angelico 
wrote:
> >> On Sat, Sep 21, 2013 at 2:28 AM, Aseem Bansal  
wrote:
> >> > I hope that cleared some confusion about what I wanted to ask. I
> >> > wanted to gauge myself to find if I am progressing or not.
> >> 
> >> Well, based on my definition, that's easy to answer. Have you solved
> >> problems using Python? If you have a bunch of HTML pages and you need
> >> to get some info out of all of them by COB today, do you think "I can
> >> do that with Python", or do you think "I can do that with sed, awk,
> >> grep, and five levels of pipe"? The tools you use for an urgent job
> >> will be the ones you know.
> >> 
> >> ChrisA
> > 
> > Yeah I have...
> > But that was pure luck that I had done the random example that you had
> > chosen. It would be difficult to find my overall progress by the one
> > thing.
> > 
> > I am currently unemployed so the sense of urgency isn't there
> > normally. That's why I asked this question. But I got your point.
> 
> It wasn't exactly a random example; it's an extremely common task
> (maybe without the "must be done today" restriction), and one that
> Python happens to do fairly well. :)
> 
> There was a time, back in the 1990s, when REXX was my primary
> language. (We were exclusively an OS/2 shop at the time, so it was a
> good choice.) If I needed to write a quick script, it would be in
> REXX. If I needed to parse text, I'd use REXX. If I wanted a GUI app,
> I'd write it in VX-REXX. Later on, when I needed to write Windows
> code, I tended to use C++. It wasn't till the late 2000s that I
> started using Python for those sorts of jobs - even though I'd met the
> language back in the 90s - indicating that that's when I actually knew
> the language.
> 
> ChrisA

That also brings back fond memories of the days of the amiga, Chris.

We had a huge superset of REXX called ARexx, which brought every system 
call that AmigaDOS had right into the script writers usage menu.  Jim Hines 
and I wrote the only cron the amiga ever had that didn't busy wait, so cpu 
usage was minimal.  Called it EzCron. Gave it away. Then since the x10 
stuff for home automation was /the/ system back in the day, we wrote 
EzHome, which had an MUI driven gui, and sold that for a time.  It, ARexx, 
was written by a William Hawes, and sold thru the commie dealer chains at 
the time.  I've no clue whatever became of that gentleman after that, but 
it came to light much that he never got a dime for writing ARexx from those 
2 crooks that bought commie and moved it to the Bahamas where he, nor 
anyone else, could sue to collect.  I did note that for many years, there 
was a subdir on kernel.org for him to work in, but to my knowledge it was 
empty when I downloaded and built my first x86 based linux kernel in early 
1998, and remained empty till whenever.

I was quite pleased to see that there was a Rexx/Regina for linux, and for 
about 10 minutes thought I could make use of the library of ARexx code Jim 
& I had carved up and had running on the amiga, but was very disappointed 
to see that Regina wasn't coupled to the os itself in any way, causing our 
scripts to barf and exit within the first 3 or 4 lines of code.

Our first web page at WDTV.com in the winter of 1999-2000 was served up on 
a dialup circuit, by an ARexx script we wrote, from an amiga 2000.

Heady days, those, while the dosboxes were still struggling with trumpet, 
and choking on the all the amiga, pdp and VAX dust. But time marches on, 
while the amiga didn't.

I've seen python doing some heady stuff in the last 5 years, but the 
learning curve is pretty steep for my now aging wet ram, which will be 79 
years old in a few days, so the scripting language here at the Heskett 
Ranchette is bash, and there is quite a boatload of that running as 
background daemons right now.  So I lurk, reading what goes by, hoping I'll 
learn enough python from osmosis to get comfortable with it.  From all 
indications, it is todays "ARexx" of scripting languages.

I'll get me coat now. :)


Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
My web page:  should be up!

As pointed out in a followup, Real Perl Programmers prefer things to be
visually distinct.
-- Larry Wall in <[email protected]>
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
 law-abiding citizens.
-- 
https://mail.python.org/mailman/listinfo/python-list


TypeError: only length-1 arrays can be converted to Python

2013-09-20 Thread D.YAN ESCOLAR RAMBAL
this the code,
__
import math
import numexpr as ne
import matplotlib.pyplot as plt
import numpy as np
import numba as nb


M = 10
A = 10
D = 0.1
xmin = -4
xmax = 4
n = 800
tfinal = 3
tinicial = 1

# GENERANDO VECTOR CON PUNTOS DE DISCRETIZACION X ESPACIADOS
x= np.linspace(xmin, xmax, n)

#GENERANDO FUNCION ANALITICA
def Cdifuana(M,A,D,x,t):
temp = A*math.sqrt(4*math.pi*D*t);
Cdifuana = (M/temp)*math.exp(-x**2 /(4*D*t))

#GENERANDO CONDICION INICIAL

C=(Cdifuana(M,A,D,x,tinicial))
___

In this code, I try obtain graph comparative  the analytic and numerical
solution for the diffusion equation in 1D, but whe  I define  the analytic
function, run the phase, the compilator show me this message.

Traceback (most recent call last):
  File "D:\Yan\Documents\Aptana Studio 3 Workspace\DIF1DMEDYER\SOLUCION
NUMERICA PARA LA ECUACION DE LA DIFUSION EN 1D DYER", line 34, in 
C=(Cdifuana(M,A,D,x,tinicial))
  File "D:\Yan\Documents\Aptana Studio 3 Workspace\DIF1DMEDYER\SOLUCION
NUMERICA PARA LA ECUACION DE LA DIFUSION EN 1D DYER", line 32, in Cdifuana
Cdifuana = (M/temp)*math.exp(-x**2 /(4*D*t))
TypeError: only length-1 arrays can be converted to Python

-- 

*Gracias, cordialmente, *

*
*

*
*

*ING. YANETH ESCOLAR RAMBAL*

*HAFI Engineering & Consulting GmbH*

*CEL: + 57 3166257245*

*TEL: + 57 (1) 6508308*

*TEL: ++43 5522 77924 0*

*Fax: ++43 5522 74938*

*Dir : Cll 72f no. 113-21 Torre 5 - 604  Bogotá Colombia*

*   Muehletorplatz 4-6, A-6800 Feldkirch, Austria*

   *www.hafi.cc/en/environ_en.htm*
-- 
https://mail.python.org/mailman/listinfo/python-list