Re: [Tutor] getting TypeError: float() argument must be a string or a number

2013-04-26 Thread Jerry Hill
On Fri, Apr 26, 2013 at 8:05 PM, bob gailer  wrote:

>  - Provide some of your program (all of it if not too long) as part of
> the email body.
>

​And if your program is too long to comfortably post in the body of an
email​, there's some great advice about how to trim large amounts of code
down to a sample that demonstrates your problem here: http://sscce.org/

In fact, I've often found this technique useful for general debugging --
trimming a large piece of misbehaving code down to the essentials will
often lead you to seeing your error once some of the surrounding complexity
is removed.

-- 
Jerry
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] getting TypeError: float() argument must be a string or a number

2013-04-26 Thread bob gailer

On 4/26/2013 6:57 PM, Rajlaxmi Swain wrote:

Welcome to the tutor list. You appear to be a first-time visitor.

To help us help you:

- Tell us:

 - Which version of Python you are using

  - How you are entering and executing your program,

- Provide some of your program (all of it if not too long) as part of 
the email body.


- Include the entire traceback.

Example:

Running Python 3.3.1
Typing in the PyScripter interactive interpreter.

>>> x = [123]
>>> print(float(x))
Traceback (most recent call last):
  File "", line 301, in runcode
  File "", line 1, in 
TypeError: float() argument must be a string or a number


How can I fix this.

Examine the argument to float. Ensure it is a string or a number.

--
Bob Gailer
919-636-4239
Chapel Hill NC

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] getting TypeError: float() argument must be a string or a number

2013-04-26 Thread Steven D'Aprano

On 27/04/13 08:57, Rajlaxmi Swain wrote:

How can I fix this.


Don't call float(foo) when foo is not a string or number.


To debug this, you need to follow these steps:

1) Look at the error message. It will tell you the line number that fails.

2) Look at that line of code. What are you calling float() on?

3) What type of object is it? If you don't know, put a line just before the 
call to float and print the object and its type. E.g.:

print(type(foo), foo)
result = float(foo)


4) Think hard about why you are calling float() on something that is not a 
string or a number. This is the bug, you now just have to understand it. Is it 
a typo? Are you using the wrong variable? Maybe you haven't initialised it to a 
good value? Or there is a path through your code where the wrong value is used?

5) Write code to fix the bug.



Notice writing code is the *least* important part of debugging. First you 
investigate what causes the bug; then you think about how it happens; then and 
only then do you write code.


Also notice that *we cannot do any of this for you*. You don't show us the full error, or 
the code, or give us any context. There is no magic wand we can wave and say "do 
this and the bug will go away".


--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] getting TypeError: float() argument must be a string or a number

2013-04-26 Thread Alan Gauld

On 26/04/13 23:57, Rajlaxmi Swain wrote:

How can I fix this.


Fix what?

you've sent (part of) the error message but not what caused it nor the 
full error text.


Don't make us guess, help us to help you.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Chapter 4 Help

2013-04-26 Thread Alan Gauld

On 26/04/13 22:02, Mariel Jane Sanchez wrote:


program should calculate the number of vowels in the phrase using a for
loop. The second time, your program should use a while loop."
My code:



phrase = raw_input("Please enter a phrase: ")
VOWELS = "aeiou"
new = ""
for letter in phrase:
 if VOWELS in phrase :
 print newv


Please send the actual code, don;t retype it. The newv should be 
throwing an error so presumably you don;t have that in your

real code.

The real problem is in your 'if' test. Think about the logic there.


It keeps printing the phrase not the new string.


Not according to the code you posted, but in the real code it
may be different. Please post the real code.


How would you do this?


You are almost there. But you should be calculating the number of vowels 
not printing them... And for that you could look at the count() method 
of strings...


And the while loop should just be a conversion of the for loop to a 
while - it hardly seems worth having as an exercise (and could even

be said to be teaching you bad habits!).


2. "Write a program that gets a message from the user and prints the
message out backwards."
For this one, i honestly don't have any idea how to make a word print
backwards, I only do it with numbers. Here's my attempt code:"


If you use a while loop here you start at the highest index in the 
string and decrement the index each time.


Using a for loop you could investigate string slicing.
Or you could convert the string to a list, reverse the list and convert 
back again to a string.
Or you could use a for loop and the range function with range set to 
count backwards.


Lots of options.



import random
message = raw_input("Please enter you message:")
raw_input("Please press the enter key to our message.")
high = (message(len(100)))
low = (message(len(0)))


No idea what you think those lines do but I'm pretty sure its
not what they really do!


new = random.randrange (high, low)
print new


And even less idea what you think this might be doing.

Can you write down in English how you would do this using
pen and paper? That might help you to craft a program.


3."Write a program that prints out a string representation of a random
card from a deck of playing cards.


OK, this is a whole different can of worms, lets get the looping and 
string issues sorted out first!

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] cant autoincrement

2013-04-26 Thread Lolo Lolo

thanks so much for the code sample eryksun. its working perfectly now:)___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] getting TypeError: float() argument must be a string or a number

2013-04-26 Thread Dave Angel

On 04/26/2013 06:57 PM, Rajlaxmi Swain wrote:

How can I fix this.






I don't see any antecedents for the pronoun.

Show us some code, tell us the situation, and show us the full traceback.

Otherwise we'd just be paraphrasing the error message.  Make sure the 
argument is a string, or an int, or a float, or ...



--
DaveA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] getting TypeError: float() argument must be a string or a number

2013-04-26 Thread Rajlaxmi Swain
How can I fix this.

Thanks,
test
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Chapter 4 Help :p:

2013-04-26 Thread Paradox


On 04/27/2013 05:02 AM, Mariel Jane Sanchez wrote:

I was in Seattle for 4 days for our band trip so i miss some classes.
Chapter 4
Project 1
"Write a program that asks for a phrase, and then calculates and 
displays the number of vowels in the phrase, twice. The first time, 
your program should calculate the number of vowels in the phrase using 
a for loop. The second time, your program should use a while loop."

My code:
phrase = raw_input("Please enter a phrase: ")
VOWELS = "aeiou"
new = ""
for letter in phrase:
if VOWELS in phrase :
print newv
It keeps printing the phrase not the new string. How would you do 
this? And what am i doing wrong?

I'll take a crack at your first problem ...

Not sure what newv is - it doesn't seem to be defined anywhere but is 
called in the print statement.


In pseudocode aren't you doing something like this?

Get a phrase from the user.
Loop over the phrase looking for letters that match the letters in 
VOWELS string.

Print any matches you find.

Looks like you are getting the phrase OK, setting your vowels string OK, 
looping over the phrase OK then looking to see if the VOWELS string is 
part of the phrase - is that what you mean to do?


Keep at it, you are getting there!

thomas
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] cant autoincrement

2013-04-26 Thread eryksun
On Fri, Apr 26, 2013 at 8:45 AM, Lolo Lolo  wrote:
>
> id INTERGER Primary Key
>
> the database has a few more fields, but when i insert into it, i leave the
> id field empty as it should be done automatically, but sql complains with an
> error that i have left the field blank. If i manually put the ids in,
> everything works, but from my understanding this should be done
> automatically, aswell as it auto incrementing?

The id should be NULL.  For parameter substitution use None.

> i have two tables
> table1 (id, field 2, field 3, field 4)
> table2 (id, field 2, field 3, FOREIGN KEY (field 3) REFERENCES table1(id))

> keys, and strangely enough if i put random text into the foreign key of
> table 2 that didnt reference any ids on table1, sqlite still inserts them
> with no errors when they clearly ignore the instructions given.

The foreign keys constrain is initially disabled. There's a pragma to
enable it. Here's an example:

import sqlite3
con = sqlite3.connect(':memory:')
cur = con.cursor()

# enable foreign keys constraint
cur = cur.execute('pragma foreign_keys=on')

cur.execute('''
create table table1(
  id integer primary key, field2, field3, field4)''')

cur.execute('''
create table table2(
  id integer primary key, field2, field3,
  foreign key(field3) references table1(id))''')

cur.execute('insert into table1 values(?,?,?,?)', (None, 1, 2, 3))
cur.execute('insert into table2 values(?,?,?)', (None, 4, 1))

# this should raise
# sqlite3.IntegrityError: foreign key constraint failed
cur.execute('insert into table2 values(?,?,?)', (None, 5, 2))
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Fw: does anyone know a good module for automation

2013-04-26 Thread ALAN GAULD
Forwarding to group for info, please use replyAll on replies.
 
Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/


- Forwarded Message -
>From: Frank Schiro 
>To: Alan Gauld  
>Sent: Friday, 26 April 2013, 19:17
>Subject: Re: [Tutor] does anyone know a good module for automation
> 
>
>
>
>
>
>On Fri, Apr 26, 2013 at 1:26 PM, Alan Gauld  wrote:
>
>On 26/04/13 16:28, Frank Schiro wrote:
>>
>>Pywinauto is not working with this application that opens from the
>>>internet via javascript. Its not in a browser, its a complete
>>>application thats not installed on the computer just installed on the
>>>internet.
>>>
>>That sounds very dodgy, it would be a huge gaping security
>>issue.
>>
>>Are you sure its not running in a separate browser
>>window - possibly as a Java applet?
>>
>>How does it appear in the Windows Task Manager? Is it a separate process? If 
>>so what is it called? 
>>
>>
>>
>>Pywinauto sees the window...but cant find any controls and does not
>>>recognize menu items, neither does its helper program swapy. Does anyone
>>>know how I could automate a program like this ?
>>>
>>Not without a lot more detail about the runtime environment. 
>>
>>
>>
>>Also I dont like sikuli, because I hate its interpreter.
>>>
>>Errr, where does sikuli fit in? I've never heard of it. 
>>
>>
>>-- 
>>Alan G
>>Author of the Learn to Program web site
>>http://www.alan-g.me.uk/
>>
>>___
>>Tutor maillist  -  Tutor@python.org
>>To unsubscribe or change subscription options:
>>http://mail.python.org/mailman/listinfo/tutor
>>
>
> 
> 
>It might be a java applet ? I see 2 processes called "java.exe" in processes 
>tab, but applications tab says the application name, ACSR
>sikuli is an automation open source thing that uses print screen.
> 
>
>___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Chapter 4 Help

2013-04-26 Thread Mariel Jane Sanchez
I was in Seattle for 4 days for our band trip so i miss some classes.
Chapter 4
Project 1
"Write a program that asks for a phrase, and then calculates and displays the 
number of vowels in the phrase, twice. The first time, your program should 
calculate the number of vowels in the phrase using a for loop. The second time, 
your program should use a while loop."
My code: 
phrase = raw_input("Please enter a phrase: ")
VOWELS = "aeiou"
new = ""
for letter in phrase:
    if VOWELS in phrase :
        print newv 
It keeps printing the phrase not the new string. How would you do this? And 
what am i doing wrong?
2. "Write a program that gets a message from the user and prints the message 
out backwards."
For this one, i honestly don't have any idea how to make a word print 
backwards, I only do it with numbers. Here's my attempt code:"
import random
message = raw_input("Please enter you message:")
raw_input("Please press the enter key to our message.")
high = (message(len(100)))
low = (message(len(0)))
new = random.randrange (high, low)
print new
So how do you put the words backwards?
3."Write a program that prints out a string representation of a random card 
from a deck of playing cards. The program should use either "A", 
"2","3","4","5","6","7","8","9","10","J","Q" or "K" for the value of the card 
and either "c","h","s" or "d" for the suit. So, if the program randomly selects 
the jack of clubs, it should display 'Jc.' Use one tuple to represent all of 
the possible card values and another tuple for the possible suits."

In the simplest way, how do you do this?
Thanks in advance___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] symlinking dirs with spaces

2013-04-26 Thread eryksun
On Fri, Apr 26, 2013 at 8:10 AM, mike  wrote:
>
> def link():
> print "Adding %s to %s..." % (origFul, loadDir)
> os.symlink('origFul', 'media')

Your arguments for symlink() are string literals. How about this?

LOAD_DIR = "/opt/data/music/load"

def link(media):
src = os.path.abspath(media)
dst = os.path.join(LOAD_DIR, os.path.basename(media))
print "Adding %s to %s..." % (src, LOAD_DIR)
os.symlink(src, dst)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] cant autoincrement

2013-04-26 Thread Lolo Lolo
what does your insert statement look like? According to the documentation 
(http://www.sqlite.org/faq.html#q1):

 "whenever you insert a NULL into that column of the table, the NULL
is automatically converted into (1 + the highest value)." 

The insert statement should look like:
 
"INSERT INTO t1 VALUES(NULL,123);

 i included the null, my results are: 
    
cursor.execute("INSERT into person VALUES(NULL, arg1, arg2)")
 
my result is:
 
(None, value1, value2) #the key being None :(
 
also thanks for the link___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] cant autoincrement

2013-04-26 Thread bob gailer

On 4/26/2013 8:45 AM, Lolo Lolo wrote:
I'm doing a test database with sqlite and have run into some problems. 
in my 1st table i have an id field:

id INTERGER Primary Key
... when i insert into it, i leave the id field empty
what does your insert statement look like? According to the 
documentation (http://www.sqlite.org/faq.html#q1):


 "whenever you insert a NULL into that column of the table, the NULL is 
automatically converted into (1 + the highest value)."


The insert statement should look like:

"INSERT INTO t1 VALUES(NULL,123);

I suggest you join 
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users - as this 
is the preferred place to ask sqlite questions.


--
Bob Gailer
919-636-4239
Chapel Hill NC

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] does anyone know a good module for automation

2013-04-26 Thread Alan Gauld

On 26/04/13 16:28, Frank Schiro wrote:

Pywinauto is not working with this application that opens from the
internet via javascript. Its not in a browser, its a complete
application thats not installed on the computer just installed on the
internet.


That sounds very dodgy, it would be a huge gaping security
issue.

Are you sure its not running in a separate browser
window - possibly as a Java applet?

How does it appear in the Windows Task Manager? Is it a separate 
process? If so what is it called?



Pywinauto sees the window...but cant find any controls and does not
recognize menu items, neither does its helper program swapy. Does anyone
know how I could automate a program like this ?


Not without a lot more detail about the runtime environment.


Also I dont like sikuli, because I hate its interpreter.


Errr, where does sikuli fit in? I've never heard of it.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] does anyone know a good module for automation

2013-04-26 Thread Frank Schiro
Pywinauto is not working with this application that opens from the internet
via javascript. Its not in a browser, its a complete application thats not
installed on the computer just installed on the internet.

Pywinauto sees the window...but cant find any controls and does not
recognize menu items, neither does its helper program swapy. Does anyone
know how I could automate a program like this ? I guess something about it
is not the same as normal installed on your own computer programs... Also I
dont like sikuli, because I hate its interpreter.

On Sat, Apr 20, 2013 at 8:28 PM, Alan Gauld wrote:

> On 20/04/13 23:07, Frank Schiro wrote:
>
>>
>> Unless you think pywinauto would work in a game envoirnment ? I think it
>> might but have not tried it because no games on my pc... I just know it
>> didnt work for internet explorer.
>>
>
> I don't know pywinauto but the lowest common denominator on Windows is the
> Win32 API and the Windows messages. You can use either ctypes or pythonwin
> to access those and/or create your own to simulate button presses and mouse
> clicks etc. Doing that you can automate anything in windows, but its a non
> trivial, error prone and frustrating exercise so its better to get a higher
> level library if you can.
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] symlinking dirs with spaces

2013-04-26 Thread Dave Angel

On 04/26/2013 08:10 AM, mike wrote:

Hi all,

I wrote a cli script for syncing my music to a USB mass storage device
like a phone etc. all it does is it creates a symlink in a dir to
whatever folder i pass as an argument via ./addsync DIR . My problem is
i'm having trouble dealing with directories with spaces. when using
os.symlink I get the error below and when using subprocess it creates
individual directories for the words separated by white space. any help
would be appreciated on how to approach this.thanks!

This is the script:

#!/usr/bin/env python
import os
from sys import argv
import subprocess
script, media = argv

# This is the directory you will sync the symbolic links from, to the
device.
loadDir = "/opt/data/music/load/"

# This is the destination folder, whatever folder the device is mounted to.
destDir = "/media/MOT_"

# Get the current working directory
origDir = os.getcwd()

# Glob the current working directory and the "media" argument together
# to form a full file path
origFul = os.path.join('%s' % origDir, '%s' % media)

linkDir = "ln -s %s %s" % (origFul, loadDir)

# Command to sync if media == "push"
syncCom = "rsync -avzL %s %s" % (loadDir, destDir)

def link():
 print "Adding %s to %s..." % (origFul, loadDir)
 os.symlink('origFul', 'media')
#subprocess.call(linkDir, shell=True)


By using shell=True, you're forcing your OS's shell to interpret the 
line.  If you insist on that approach, you'll need to escape any 
embedded spaces, same as you would in the terminal.


Easier and safer would be to pass the list of argument to 
subprocess.call, the way these docs show:


   http://docs.python.org/2/library/subprocess.html#subprocess.call

So instead of linkDir looking like "ln -s file 1 file2"  it should look 
like:

["ln", "-s", "file 1", "file2"]
and you'd use it like:
subprocess.call(linkDir)

Avoiding the shell=True is faster, safer, and usually much easier.



--
DaveA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] cant autoincrement

2013-04-26 Thread Lolo Lolo
I'm doing a test database with sqlite and have run into some problems. in my 
1st table i have an id field: 
 
id INTERGER Primary Key
 
the database has a few more fields, but when i insert into it, i leave the id 
field empty as it should be done automatically, but sql complains with an error 
that i have left the field blank. If i manually put the ids in, everything 
works, but from my understanding this should be done automatically, aswell as 
it auto incrementing? 
 
i have two tables 
table1 (id, field 2, field 3, field 4)
table2 (id, field 2, field 3, FOREIGN KEY (field 3) REFERENCES table1(id))
 
i initially had a problem as foreign keys is not enabled by default but as my 
auto increment isnt working, can i just ask what does sql insert into field 3 
of table2 as its a foreign key. Does it automatically insert the correspond id 
of table1, or is it up to me to manually insert the correct data into table2 
that match with the keys on table1? I ask only because i havent had a chance to 
try it myself as i still have a problem with the keys, and strangely enough if 
i put random text into the foreign key of table 2 that didnt reference any ids 
on table1, sqlite still inserts them with no errors when they clearly ignore 
the instructions given.___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] symlinking dirs with spaces

2013-04-26 Thread mike

Hi all,

I wrote a cli script for syncing my music to a USB mass storage device 
like a phone etc. all it does is it creates a symlink in a dir to 
whatever folder i pass as an argument via ./addsync DIR . My problem is 
i'm having trouble dealing with directories with spaces. when using 
os.symlink I get the error below and when using subprocess it creates 
individual directories for the words separated by white space. any help 
would be appreciated on how to approach this.thanks!


This is the script:

#!/usr/bin/env python
import os
from sys import argv
import subprocess
script, media = argv

# This is the directory you will sync the symbolic links from, to the 
device.

loadDir = "/opt/data/music/load/"

# This is the destination folder, whatever folder the device is mounted to.
destDir = "/media/MOT_"

# Get the current working directory
origDir = os.getcwd()

# Glob the current working directory and the "media" argument together
# to form a full file path
origFul = os.path.join('%s' % origDir, '%s' % media)

linkDir = "ln -s %s %s" % (origFul, loadDir)

# Command to sync if media == "push"
syncCom = "rsync -avzL %s %s" % (loadDir, destDir)

def link():
print "Adding %s to %s..." % (origFul, loadDir)
os.symlink('origFul', 'media')
#subprocess.call(linkDir, shell=True)

def sync():
print "Syncing the contents of %s to %s" % (loadDir, destDir)
subprocess.call(syncCom, shell=True)

if media == "push":
sync()
else:
link()



rev@sheridan:~/code$ ./addsync SPACES\ TEST/
Adding /home/rev/code/SPACES TEST/ to /opt/data/music/load/...
Traceback (most recent call last):
  File "./addsync", line 37, in 
link()
  File "./addsync", line 27, in link
os.symlink('origFul', 'media')
OSError: [Errno 17] File exists
rev@sheridan:~/code$ ls -lh /opt/data/music/load/
total 4.0K
-rwxrwxr-x 1 rev rev 225 Apr 11 09:26 addsync
lrwxrwxrwx 1 rev rev  34 Oct 29 20:30 CCR - Best of CCR -> 
../classic_rock/CCR - Best of CCR/

rev@sheridan:~/code$

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] sha-256 without using hashlib

2013-04-26 Thread Dave Angel

On 04/26/2013 05:08 AM, Arijit Ukil wrote:

I like to implement sha-256 without using implement. It is easy using
hashlib as:

import hashlib
m = hashlib.sha256()
m.update("hi")
print m.hexdigest()

If anybody has pointer on sha-256 implemented without using hashlib
library, please share.



If you'd tell us WHY you don't want to use a stdlib, we might be able to 
help.


For example, perhaps you're supposed to code it for an assignment, and 
show that you understand the algorithms.  In that case, look up the 
algorithm on the net, and start from there.


   http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf

Or you could be assuming that you can do a better, faster or whatever 
job than the library.  In that case, consider using numpy, or Cython, or 
a C compiler.


Or perhaps you didn't realize you could get the sources to hashlib 
online.  I believe some are in Python, and some in C, so that might not 
help you if your goal is one of the previous ones.



--
DaveA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] sha-256 without using hashlib

2013-04-26 Thread Arijit Ukil
I like to implement sha-256 without using implement. It is easy using 
hashlib as:

import hashlib
m = hashlib.sha256()
m.update("hi")
print m.hexdigest()

If anybody has pointer on sha-256 implemented without using hashlib 
library, please share.

Regards,
Arijit Ukil
Tata Consultancy Services
Mailto: arijit.u...@tcs.com
Website: http://www.tcs.com

Experience certainty.   IT Services
Business Solutions
Outsourcing

=-=-=
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor