PyWart fixed mostly, was: Re: Python Gotcha's?

2013-01-22 Thread Bryan
On Apr 14 2012, 2:47 pm I wrote: > Miki Tebeka wrote: > > If you have an interesting/common "Gotcha" (warts/dark corners ...) please > > share. > > Python 3(K) likes to use the same '.py' file extension as its > incompatible predecessors, and in some/many/most *nix implementations, > it likes to i

Re: handling return codes from CTYPES

2013-01-22 Thread Steve Simmons
Duncan, Mike, MRAB, Thank you. New technology set, same forgotten lesson - RTFM (all of it!). Thanks also for the clarification on discarding objects and Garbage Collection. Looks like I'll have to turn a large chunk of my previous understanding of (mainframe) languages 'inside out'. I'm j

Re: Sending a broadcast message using raw sockets

2013-01-22 Thread Rob Williscroft
Peter Steele wrote in news:[email protected] in comp.lang.python: > On Monday, January 21, 2013 1:10:06 AM UTC-8, Rob Williscroft wrote: >> Peter Steele wrote in >> >> news:[email protected] in >> >> comp.lang.python: >>

Retrieving the full command line

2013-01-22 Thread Tim Golden
[Python 2.7/3.3 (and hg tip) running on Windows. Not Windows-specific, though]. I use the python -mpackage incantation to run a package which has a __main__.py module and which uses relative imports internally. I'm developing under cherrypy which includes a reloader for development. The reloader

Using filepath method to identify an .html page

2013-01-22 Thread Ferrous Cranus
Hello, i decided to switch from embedding string into .html to actually grab the filepath in order to identify it: # = # open current html template and get the page ID number # ===

Re: Using filepath method to identify an .html page

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 02:07:54 -0800, Ferrous Cranus wrote: > Hello, i decided to switch from embedding string into .html to actually > grab the filepath in order to identify it: What do you think "the filepath" means, and how do you think you would grab it? I can only guess you mean the full pat

Re: Using filepath method to identify an .html page

2013-01-22 Thread Ferrous Cranus
# == # produce a hash based on html page's filepath and convert it to an integet, that will be uses to identify the page itself. # == pin = int( hashlib.md5( htmlpage ) ) I just tried that but it pro

Re: Using filepath method to identify an .html page

2013-01-22 Thread Ferrous Cranus
# # produce a hash string based on html page's filepath and convert it to an integer, that will then be used to identify the page itself #

Re: Using filepath method to identify an .html page

2013-01-22 Thread Lele Gaifax
Ferrous Cranus writes: > pin = int( hashlib.md5( htmlpage ) ) > > This fails. why? > > htmlpage = a string respresenting the absolute path of the requested .html > file > hashlib.md5( htmlpage ) = conversion of the above string to a hashed string No, that statement does not "convert" a string i

Re: Using filepath method to identify an .html page

2013-01-22 Thread Chris Angelico
On Tue, Jan 22, 2013 at 10:53 PM, Ferrous Cranus wrote: > # == > # produce a hash based on html page's filepath and convert it to an integet, > that will be uses to identify the page itself. > # == > >

Re: Using filepath method to identify an .html page

2013-01-22 Thread Dave Angel
On 01/22/2013 07:02 AM, Ferrous Cranus wrote: # # produce a hash string based on html page's filepath and convert it to an integer, that will then be used to iden

Re: Using filepath method to identify an .html page

2013-01-22 Thread Ferrous Cranus
Τη Τρίτη, 22 Ιανουαρίου 2013 2:29:21 μ.μ. UTC+2, ο χρήστης Dave Angel έγραψε: > On 01/22/2013 07:02 AM, Ferrous Cranus wrote: > > > # > > > > > # produce a hash st

Re: Using filepath method to identify an .html page

2013-01-22 Thread Ferrous Cranus
Τη Τρίτη, 22 Ιανουαρίου 2013 2:47:16 μ.μ. UTC+2, ο χρήστης Ferrous Cranus έγραψε: > Τη Τρίτη, 22 Ιανουαρίου 2013 2:29:21 μ.μ. UTC+2, ο χρήστης Dave Angel έγραψε: > > > On 01/22/2013 07:02 AM, Ferrous Cranus wrote: > > > > > > > # > > > =

Re: Using filepath method to identify an .html page

2013-01-22 Thread Chris Angelico
On Tue, Jan 22, 2013 at 11:47 PM, Ferrous Cranus wrote: > What i want to do, is to associate a number to an html page's absolute path > for to be able to use that number for my database relations instead of the > BIG absolute path string. > > so to get an integer out of a string i would just hav

Re: Using filepath method to identify an .html page

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 04:47:16 -0800, Ferrous Cranus wrote: > htmlpage = a string respresenting the absolute path of the requested > .html file That is a very misleading name for a variable. The contents of the variable are not a html page, but a file name. htmlpage = "/home/steve/my-web-page.ht

Re: handling return codes from CTYPES

2013-01-22 Thread Chris Angelico
On Tue, Jan 22, 2013 at 7:02 PM, Steve Simmons wrote: > Thanks also for the clarification on discarding objects and Garbage > Collection. Looks like I'll have to turn a large chunk of my previous > understanding of (mainframe) languages 'inside out'. > > I'm just wondering how often I'll have to

Re: Using filepath method to identify an .html page

2013-01-22 Thread Ferrous Cranus
Τη Τρίτη, 22 Ιανουαρίου 2013 3:04:41 μ.μ. UTC+2, ο χρήστης Steven D'Aprano έγραψε: > What do you expect int("my-web-page.html") to return? Should it return 23 > or 794 or 109432985462940911485 or 42? I expected a unique number from the given string to be produced so i could have a (number <=>

Re: Using filepath method to identify an .html page

2013-01-22 Thread Chris Angelico
On Wed, Jan 23, 2013 at 12:57 AM, Ferrous Cranus wrote: > Τη Τρίτη, 22 Ιανουαρίου 2013 3:04:41 μ.μ. UTC+2, ο χρήστης Steven D'Aprano > έγραψε: > >> What do you expect int("my-web-page.html") to return? Should it return 23 >> or 794 or 109432985462940911485 or 42? > > I expected a unique number fr

Re: Retrieving the full command line

2013-01-22 Thread Terry Reedy
On 1/22/2013 4:24 AM, Tim Golden wrote: [Python 2.7/3.3 (and hg tip) running on Windows. Not Windows-specific, though]. I use the python -mpackage incantation to run a package which has a __main__.py module and which uses relative imports internally. I'm developing under cherrypy which includes

Re: Using filepath method to identify an .html page

2013-01-22 Thread Ferrous Cranus
Τη Τρίτη, 22 Ιανουαρίου 2013 4:33:03 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε: > On Wed, Jan 23, 2013 at 12:57 AM, Ferrous Cranus > wrote: > > > Τη Τρίτη, 22 Ιανουαρίου 2013 3:04:41 μ.μ. UTC+2, ο χρήστης Steven D'Aprano > > έγραψε: > > > > > >> What do you expect int("my-web-page.html") t

Re: Using filepath method to identify an .html page

2013-01-22 Thread Dave Angel
On 01/22/2013 09:55 AM, Ferrous Cranus wrote: Τη Τρίτη, 22 Ιανουαρίου 2013 4:33:03 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε: On Wed, Jan 23, 2013 at 12:57 AM, Ferrous Cranus wrote: Τη Τρίτη, 22 Ιανουαρίου 2013 3:04:41 μ.μ. UTC+2, ο χρήστης Steven D'Aprano έγραψε: What do you expec

Re: Retrieving the full command line

2013-01-22 Thread Tim Golden
On 22/01/2013 14:53, Terry Reedy wrote: > On 1/22/2013 4:24 AM, Tim Golden wrote: >> [Python 2.7/3.3 (and hg tip) running on Windows. Not Windows-specific, >> though]. >> >> I use the python -mpackage incantation to run a package which has a >> __main__.py module and which uses relative imports int

Re: Using filepath method to identify an .html page

2013-01-22 Thread Chris Angelico
On Wed, Jan 23, 2013 at 1:55 AM, Ferrous Cranus wrote: > I insist, perhaps compeleld, to use a key to associate a number to a filename. > Would you help please? > > I dont know this is supposed to be written. i just know i need this: > > number = function_that_returns_a_number_out_of_a_string( >

Re: Sending a broadcast message using raw sockets

2013-01-22 Thread Peter Steele
I just tried running you code, and the "sendto" call fails with "Network is unreachable". That's what I expected, based on other tests I've done. That's why I was asking about how to do raw sockets, since tools like dhclient use raw sockets to do what they do. It can clearly be duplicated in Pyt

Re: Using filepath method to identify an .html page

2013-01-22 Thread Ferrous Cranus
Τη Τρίτη, 22 Ιανουαρίου 2013 5:05:49 μ.μ. UTC+2, ο χρήστης Dave Angel έγραψε: > On 01/22/2013 09:55 AM, Ferrous Cranus wrote: > > > Τη Τρίτη, 22 Ιανουαρίου 2013 4:33:03 μ.μ. UTC+2, ο χρήστης Chris Angelico > > έγραψε: > > >> On Wed, Jan 23, 2013 at 12:57 AM, Ferrous Cranus > >> wrote: > > >>

Re: Using filepath method to identify an .html page

2013-01-22 Thread Chris Angelico
On Wed, Jan 23, 2013 at 2:21 AM, Ferrous Cranus wrote: > Why the hell > > pin = int ( '/home/nikos/public_html/index.html' ) > > fails? because it has slashes in it? What do you expect it to return? 141592653589793? Go through the Python tutorial. Better yet, find a book that distinguishes betwe

Re: Using filepath method to identify an .html page

2013-01-22 Thread Peter Otten
Ferrous Cranus wrote: > I insist, perhaps compeleld, to use a key to associate a number to a > filename. Would you help please? > > I dont know this is supposed to be written. i just know i need this: > > number = function_that_returns_a_number_out_of_a_string( > absolute_path_of_a_html_file) >

Re: Else statement executing when it shouldnt

2013-01-22 Thread Thomas Boell
On Mon, 21 Jan 2013 06:07:08 +0100 René Klačan wrote: > Examples: > > # else branch will be executed > i = 0 > while i < 5: > i += 1 > else: > print('loop is over') > > > # else branch will be executed > i = 0 > while i < 5: > i += 1 > if i == 7: > print('i == 7') >

Re: Else statement executing when it shouldnt

2013-01-22 Thread Chris Angelico
On Wed, Jan 23, 2013 at 2:39 AM, Thomas Boell wrote: > Huh?! I would have expected all your examples to raise a SyntaxError or > IndentationError. Why don't they? Is 'else' not required to have a > matching 'if'? Other things can have else, including 'for' and 'while' loops. :) ChrisA -- http:/

Re: Using filepath method to identify an .html page

2013-01-22 Thread Ferrous Cranus
Thank you but the number needs to be a 4-digit integer only, if its to be stored in the database table correctly. pin = int( htmlpage.encode("hex"), 16 ) I just tried whayt you gace me This produces a number of: 140530319499494727...677522822126923116L Visit http://superhost.gr to see that dis

Re: Else statement executing when it shouldnt

2013-01-22 Thread Duncan Booth
Thomas Boell wrote: > Huh?! I would have expected all your examples to raise a SyntaxError or > IndentationError. Why don't they? Is 'else' not required to have a > matching 'if'? > Matching 'if' or 'for' or 'while'. See http://docs.python.org/2/tutorial/controlflow.html#break-and-continue-sta

Re: Else statement executing when it shouldnt

2013-01-22 Thread Duncan Booth
Duncan Booth wrote: > Matching 'if' or 'for' or 'while'. > or of course 'try'. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Else statement executing when it shouldnt

2013-01-22 Thread Thomas Boell
On Wed, 23 Jan 2013 02:42:27 +1100 Chris Angelico wrote: > On Wed, Jan 23, 2013 at 2:39 AM, Thomas Boell wrote: > > Huh?! I would have expected all your examples to raise a SyntaxError or > > IndentationError. Why don't they? Is 'else' not required to have a > > matching 'if'? > > Other things

Re: Using filepath method to identify an .html page

2013-01-22 Thread Ferrous Cranus
Τη Τρίτη, 22 Ιανουαρίου 2013 5:25:42 μ.μ. UTC+2, ο χρήστης Peter Otten έγραψε: > Ferrous Cranus wrote: > > > > > I insist, perhaps compeleld, to use a key to associate a number to a > > > filename. Would you help please? > > > > > > I dont know this is supposed to be written. i just know i n

Re: Else statement executing when it shouldnt

2013-01-22 Thread Chris Angelico
On Wed, Jan 23, 2013 at 2:48 AM, Thomas Boell wrote: > On Wed, 23 Jan 2013 02:42:27 +1100 > Chris Angelico wrote: > >> On Wed, Jan 23, 2013 at 2:39 AM, Thomas Boell wrote: >> > Huh?! I would have expected all your examples to raise a SyntaxError or >> > IndentationError. Why don't they? Is 'else

Re: Using filepath method to identify an .html page

2013-01-22 Thread Chris Angelico
On Wed, Jan 23, 2013 at 2:59 AM, Ferrous Cranus wrote: > I just need a way to CONVERT a string(absolute path) to a 4-digit unique > number with INT!!! That's all i want!! But i cannot make it work :( Either you are deliberately trolling, or you have a major comprehension problem. Please go back

Re: Using filepath method to identify an .html page

2013-01-22 Thread Dave Angel
On 01/22/2013 10:46 AM, Ferrous Cranus wrote: Thank you but the number needs to be a 4-digit integer only, if its to be stored in the database table correctly. pin = int( htmlpage.encode("hex"), 16 ) I just tried whayt you gace me This produces a number of: 140530319499494727...67752282212692

Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Ferrous Cranus
I just need a way to CONVERT a string(absolute path) to a 4-digit unique number with INT!!! That's all i want!! But i cannot make it work :( And the best part is that "that" number must be able to turn back into a path. This way i DON'T EVEN HAVE TO STORE THE ACTUAL HTML PAGE'S ABSOLUTE PATH

RE: Using filepath method to identify an .html page

2013-01-22 Thread Leonard, Arah
> Thank you but the number needs to be a 4-digit integer only, if its to be > stored in the database table correctly. Okay, I think we need to throw the flag on the field at this point. What you're asking for has gone into a realm where you clearly don't even appear to understand what you're a

RE: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Leonard, Arah
> I just need a way to CONVERT a string(absolute path) to a 4-digit unique > number with INT!!! That's all i want!! But i cannot make it work :( > > And the best part is that "that" number must be able to turn back into a path. > > This way i DON'T EVEN HAVE TO STORE THE ACTUAL HTML PAGE'S ABSOL

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Mark Lawrence
On 22/01/2013 16:15, Ferrous Cranus wrote: I just need a way to CONVERT a string(absolute path) to a 4-digit unique number with INT!!! That's all i want!! But i cannot make it work :( And the best part is that "that" number must be able to turn back into a path. This way i DON'T EVEN HAVE TO S

Re: Uniquely identifying each & every html template

2013-01-22 Thread John Gordon
In <[email protected]> Ferrous Cranus writes: > > If that's the case, then I figure you have about 3 choices: > > 1) use the file path as your key, instead of requiring a number > No, i cannot, because it would mess things at a later time on when i for > exam

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Dave Angel
On 01/22/2013 11:15 AM, Ferrous Cranus wrote: I just need a way to CONVERT a string(absolute path) to a 4-digit unique number with INT!!! That's all i want!! But i cannot make it work :( And the best part is that "that" number must be able to turn back into a path. This way i DON'T EVEN HAVE T

Re: Using filepath method to identify an .html page

2013-01-22 Thread John Gordon
In Ferrous Cranus writes: > I just need a way to CONVERT a string(absolute path) to a 4-digit unique > number with INT!!! That's all i want!! But i cannot make it work :( Given your requirements, I don't think it *can* work. There's just no way to do it. How can the computer guarantee that b

Re: Sending a broadcast message using raw sockets

2013-01-22 Thread Corey LeBleu
If you don't *have* to use the actual socket library, you might want to have a look at scapy. It's a packet manipulation program/library. It might make things a little easier. http://www.secdev.org/projects/scapy/ On Jan 22, 2013 9:17 AM, "Peter Steele" wrote: > I just tried running you code,

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Ferrous Cranus
Τη Τρίτη, 22 Ιανουαρίου 2013 6:27:32 μ.μ. UTC+2, ο χρήστης Leonard, Arah έγραψε: > > I just need a way to CONVERT a string(absolute path) to a 4-digit unique > > number with INT!!! That's all i want!! But i cannot make it work :( > > > > > > And the best part is that "that" number must be able

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread D'Arcy J.M. Cain
On Tue, 22 Jan 2013 16:27:32 + "Leonard, Arah" wrote: > > I just need a way to CONVERT a string(absolute path) to a 4-digit > > unique number with INT!!! That's all i want!! But i cannot make it > > work :( Why bother? Just wish for a zillion dollars and then you never have to program again.

Is PyArg_ParseTuple necessary to parse arguments?

2013-01-22 Thread rahulgarg44
Or can I just loop through the argument tuple manually by using something like PyTuple_GET_ITEM(args,i), then putting manual code to convert the objects to appropriate C type? The use case is that I am interfacing Python with another interpreter and do not know the type and number of arguments

RE: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Leonard, Arah
> No need, to turn the number back to a path anymore, just the path to a > number, to identify the specific .html page > > Can this be done? Guaranteed to be unique? Not even remotely possible. Even with a lookup table approach (which defeats your purpose of not storing the path) with 4 digit

Re: Using filepath method to identify an .html page

2013-01-22 Thread rusi
On Jan 22, 8:59 pm, Ferrous Cranus wrote: > I just need a way to CONVERT a string(absolute path) to a 4-digit unique > number with INT!!! > That's all i want!! But i cannot make it work :( I just need a way to eat my soup with a screwdriver. No I WONT use a spoon. Im starving HELP -- http://ma

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Ferrous Cranus
Τη Τρίτη, 22 Ιανουαρίου 2013 7:24:26 μ.μ. UTC+2, ο χρήστης Leonard, Arah έγραψε: > > No need, to turn the number back to a path anymore, just the path to a > > number, to identify the specific .html page > > > > > > Can this be done? > > > > Guaranteed to be unique? Not even remotely possib

Understanding while...else...

2013-01-22 Thread Terry Reedy
Several people have trouble understanding Python's while-else and for-else constructs. It is actually quite simple if one starts with if-else, which few have any trouble with. Start with, for example if n > 0: n -= 1 else: n = None The else clause is executed if and when the condition is

Re: Using filepath method to identify an .html page

2013-01-22 Thread Mark Lawrence
On 22/01/2013 17:33, rusi wrote: On Jan 22, 8:59 pm, Ferrous Cranus wrote: I just need a way to CONVERT a string(absolute path) to a 4-digit unique number with INT!!! That's all i want!! But i cannot make it work :( I just need a way to eat my soup with a screwdriver. No I WONT use a spoon.

Re: Sending a broadcast message using raw sockets

2013-01-22 Thread Peter Steele
In fact, I have used scapy in the past, but I am working in a restricted environment and don't have this package available. It provides tones more than I really need anyway, and I figured a simple raw socket send/receive can't be *that* hard. I may have to reverse engineer some C code, such as d

Re: Using filepath method to identify an .html page

2013-01-22 Thread Ferrous Cranus
Τη Τρίτη, 22 Ιανουαρίου 2013 6:55:02 μ.μ. UTC+2, ο χρήστης John Gordon έγραψε: > In Ferrous Cranus > writes: > > > > > I just need a way to CONVERT a string(absolute path) to a 4-digit unique > > > number with INT!!! That's all i want!! But i cannot make it work :( > > > > Given your requ

Re: Using filepath method to identify an .html page

2013-01-22 Thread Ferrous Cranus
Τη Τρίτη, 22 Ιανουαρίου 2013 6:23:16 μ.μ. UTC+2, ο χρήστης Leonard, Arah έγραψε: > > Thank you but the number needs to be a 4-digit integer only, if its to be > > stored in the database table correctly. > > > > Okay, I think we need to throw the flag on the field at this point. What > you're

Re: Using filepath method to identify an .html page

2013-01-22 Thread Michael Torrie
On 01/22/2013 03:07 AM, Ferrous Cranus wrote: > Now, can you pleas help me write the switch to filepath identifier? > I'am having trouble writing it. Unfortunately this isn't the way to go either. Apache uses its own config and rules to map a url to a "filepath." There's no way for Python to do

Re: Using filepath method to identify an .html page

2013-01-22 Thread Ferrous Cranus
Τη Τρίτη, 22 Ιανουαρίου 2013 7:33:00 μ.μ. UTC+2, ο χρήστης rusi έγραψε: > On Jan 22, 8:59 pm, Ferrous Cranus wrote: > > > I just need a way to CONVERT a string(absolute path) to a 4-digit unique > > number with INT!!! > > > That's all i want!! But i cannot make it work :( > > > > I just need

Re: Using filepath method to identify an .html page

2013-01-22 Thread Ferrous Cranus
Τη Τρίτη, 22 Ιανουαρίου 2013 6:11:20 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε: > On Wed, Jan 23, 2013 at 2:59 AM, Ferrous Cranus wrote: > > > I just need a way to CONVERT a string(absolute path) to a 4-digit unique > > number with INT!!! That's all i want!! But i cannot make it work :( > >

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Ferrous Cranus
Τη Τρίτη, 22 Ιανουαρίου 2013 7:24:26 μ.μ. UTC+2, ο χρήστης Leonard, Arah έγραψε: > > No need, to turn the number back to a path anymore, just the path to a > > number, to identify the specific .html page > > > > > > Can this be done? > > > > Guaranteed to be unique? Not even remotely possib

Re: Using filepath method to identify an .html page

2013-01-22 Thread Michael Torrie
I'm sorry you are getting so frustrated. There's obviously a language barrier here, but also your frustration is preventing you from thinking clearly. You need to take a step back, breath, and re-read everything that's been written to you on this thread. All your questions that can be answered h

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread John Gordon
In <[email protected]> Ferrous Cranus writes: > > pin int( htmlpage.encode("hex"), 16 ) % 1 > > > > It'll give you your number, but there are no guarantees of uniqueness. > You're looking at more blind random luck using that. > Finally!! THANK YOU VER

Re: Using filepath method to identify an .html page

2013-01-22 Thread John Gordon
In <[email protected]> Ferrous Cranus writes: > And the .html files are not even close 10.000 You said you wanted a 4-digit number. There are 10,000 different 4-digit numbers. 0001 0002 ... -- John Gordon A is for Amy, who fell

Re: Using filepath method to identify an .html page

2013-01-22 Thread MRAB
On 2013-01-22 18:26, Ferrous Cranus wrote: Τη Τρίτη, 22 Ιανουαρίου 2013 6:11:20 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε: On Wed, Jan 23, 2013 at 2:59 AM, Ferrous Cranus wrote: > I just need a way to CONVERT a string(absolute path) to a 4-digit unique number with INT!!! That's all i want!

Re: Using filepath method to identify an .html page

2013-01-22 Thread Michael Torrie
On 01/22/2013 11:13 AM, Ferrous Cranus wrote: > a) I'am a reseller, i have unlimited ftp quota, hence database space Space doesn't even come into the equation. There's virtually no difference between a 4-digit number and a 100-character string. Yes there is an absolute difference in storage spac

Re: Using filepath method to identify an .html page

2013-01-22 Thread Michael Torrie
On 01/22/2013 11:26 AM, Ferrous Cranus wrote: > which yields: > $ perl testMD5.pl > /index.html: 1066 > /about/time.html: 1547 Well do it the same with in python then. Just read the docs on the hashlib so you know what kind of object it returns and how to call methods on that object to return a

Re: Using filepath method to identify an .html page

2013-01-22 Thread Dave Angel
On 01/22/2013 01:26 PM, Ferrous Cranus wrote: sub hashit { my $url=shift; my @ltrs=split(//,$url); my $hash = 0; foreach my $ltr(@ltrs){ $hash = ( $hash + ord($ltr)) %1; } printf "%s: %0.4d\n",$url,$hash } which yields: $ perl testMD5.pl /index.html:

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Michael Torrie
On 01/22/2013 11:37 AM, Ferrous Cranus wrote: > == pin = int( > htmlpage.encode("hex"), 16 ) % 1 > == > > Can you please explain the differences to what you have posted > opposed to this perl coding? > >

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Dave Angel
On 01/22/2013 01:37 PM, Ferrous Cranus wrote: == pin = int( htmlpage.encode("hex"), 16 ) % 1 == Can you please explain the differences to what you have posted opposed to this perl coding? ===

Re: Using filepath method to identify an .html page

2013-01-22 Thread Peter Otten
Ferrous Cranus wrote: > Τη Τρίτη, 22 Ιανουαρίου 2013 6:11:20 μ.μ. UTC+2, ο χρήστης Chris Angelico > έγραψε: >> all of it. You are asking something that is fundamentally >> impossible[1]. There simply are not enough numbers to go around. > Fundamentally impossible? > > Well > > OK: How abou

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Ferrous Cranus
Τη Τρίτη, 22 Ιανουαρίου 2013 9:02:48 μ.μ. UTC+2, ο χρήστης Michael Torrie έγραψε: > On 01/22/2013 11:37 AM, Ferrous Cranus wrote: > > > == pin = int( > > > htmlpage.encode("hex"), 16 ) % 1 > > > == > >

Oportunidade: Desenvolvedor Python/Django Sênior - RJ

2013-01-22 Thread zughumancapital
Arpex Capital Seleciona: Desenvolvedor Python/Django Sênior Estamos em busca daqueles(as) que: acham que meritocracia é indispensável, programam desde a infância, possuem sede por aprender e programar e querem trabalhar muito para fazer algo especial! O desenvolvedor estará envolvido em um pr

Re: Importing class from another file

2013-01-22 Thread John Gordon
In Kevin Holleran writes: > I have a class called My_Class in a subdir called Sub_Dir. > in My_Class.py is the following > class My_Class_Connector: > def __init__(self,un,pw,qs_srv="domain.com"): > self.username = un > self.password = pw > Then I am trying to call from a

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Alan Spence
On 22 Jan 2013, at 19:28, Ferrous Cranus wrote: > Τη Τρίτη, 22 Ιανουαρίου 2013 9:02:48 μ.μ. UTC+2, ο χρήστης Michael Torrie > έγραψε: >> On 01/22/2013 11:37 AM, Ferrous Cranus wrote: >> >>> == pin = int( >> >>> htmlpage.encode("hex"), 16 ) % 1 >

Re: Understanding while...else...

2013-01-22 Thread Ethan Furman
On 01/22/2013 09:44 AM, Terry Reedy wrote: Several people have trouble understanding Python's while-else and for-else constructs. It is actually quite simple if one starts with if-else, which few have any trouble with. Start with, for example if n > 0: n -= 1 else: n = None The else clau

RE: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Leonard, Arah
> The perl code will produce the same hash for "abc.html" as for "bca.html" > That's probably one reason Leonard didn't try to transliterate the buggy code. > Actually, to give credit where it's due, it wasn't me. I just modified someone else's interesting solution in this thread and added t

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread Dave Angel
On 01/22/2013 03:30 PM, Leonard, Arah wrote: The perl code will produce the same hash for "abc.html" as for "bca.html" That's probably one reason Leonard didn't try to transliterate the buggy code. Actually, to give credit where it's due, it wasn't me. I just modified someone else's inter

Re: Importing class from another file

2013-01-22 Thread Kevin Holleran
Thanks, you got me straightened out. -- Kevin Holleran Master of Science, Computer Information Systems Grand Valley State University Master of Business Administration Western Michigan University SANS GCFA, SANS GCFE, CCNA, ISA, MCSA, MCDST, MCP "Do today what others won't, do tomorrow what other

Re: Converting a string to a number by using INT (no hash method)

2013-01-22 Thread John Gordon
In Ferrous Cranus writes: > May i sent you my code by mail so for you see whats wrong and > http://superhost.gr produces error? I tried going to that address and got some error output. I noticed this in the error dump: 186 if cursor.rowcount == 0: 187 cursor

Re: Sending a broadcast message using raw sockets

2013-01-22 Thread Chris Angelico
On Wed, Jan 23, 2013 at 4:57 AM, Peter Steele wrote: > In fact, I have used scapy in the past, but I am working in a restricted > environment and don't have this package available. It provides tones more > than I really need anyway, and I figured a simple raw socket send/receive > can't be *tha

Re: Sending a broadcast message using raw sockets

2013-01-22 Thread Peter Steele
Actually, I used to teach C, so yeah, I know it pretty well. :-) Scapy is a possibility, I just need to add it to my environment (which doesn't have a C compiler). I can jury rig something though. On Tuesday, January 22, 2013 1:19:14 PM UTC-8, Chris Angelico wrote: > On Wed, Jan 23, 2013 at 4:57

Re: Sending a broadcast message using raw sockets

2013-01-22 Thread Rob Williscroft
Peter Steele wrote in news:[email protected] in comp.lang.python: > I just tried running you code, and the "sendto" call fails with > "Network is unreachable". That's what I expected, based on other tests > I've done. That's why I was asking about how to do raw

Re: Understanding while...else...

2013-01-22 Thread Terry Reedy
On 1/22/2013 3:09 PM, Ethan Furman wrote: On 01/22/2013 09:44 AM, Terry Reedy wrote: Several people have trouble understanding Python's while-else and for-else constructs. It is actually quite simple if one starts with if-else, which few have any trouble with. Start with, for example if n > 0:

Re: Using filepath method to identify an .html page

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 11:36:31 -0700, Michael Torrie wrote: > I'm sorry you are getting so frustrated. There's obviously a language > barrier here, I don't think there is. The OP's posts have been written in excellent English. I think we've been well and truly trolled, by somebody who even uses

Re: Using filepath method to identify an .html page

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 11:36:31 -0700, Michael Torrie wrote: > I'm sorry you are getting so frustrated. There's obviously a language > barrier here, I don't think there is. The OP's posts have been written in excellent English. I think we've been well and truly trolled, by somebody who even uses

Re: pycache directories

2013-01-22 Thread monosij . forums
On Tuesday, January 22, 2013 1:01:44 AM UTC-5, Terry Reedy wrote: > > > I am doing some OO python3 where I am using multiple dirs/sub-dirs. > > > > > > So everything works fine, however when I run code __pycache__ > > > directories are being created in every directory touched by the > > > exec

Re: Using filepath method to identify an .html page

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 11:36:31 -0700, Michael Torrie wrote: > I'm sorry you are getting so frustrated. There's obviously a language > barrier here, I don't think there is. The OP's posts have been written in excellent English. I think we've been well and truly trolled, by somebody who even uses

Re: Retrieving the full command line

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 15:07:18 +, Tim Golden wrote: > On 22/01/2013 14:53, Terry Reedy wrote: >> On 1/22/2013 4:24 AM, Tim Golden wrote: >>> [Python 2.7/3.3 (and hg tip) running on Windows. Not Windows-specific, >>> though]. >>> >>> I use the python -mpackage incantation to run a package which h

Re: Uniquely identifying each & every html template

2013-01-22 Thread Michael Torrie
On 01/21/2013 08:00 AM, Ferrous Cranus wrote: > Τη Δευτέρα, 21 Ιανουαρίου 2013 2:47:54 μ.μ. UTC+2, ο χρήστης Joel > Goldstick έγραψε: >> This is trolling Ferrous. you are a troll. Go away > > Just because you cannot answer my question that doesn't make me a > troll you know. It becomes trolling

Re: Using filepath method to identify an .html page

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 09:33:00 -0800, rusi wrote: > On Jan 22, 8:59 pm, Ferrous Cranus wrote: >> I just need a way to CONVERT a string(absolute path) to a 4-digit >> unique number with INT!!! That's all i want!! But i cannot make it work >> :( > > I just need a way to eat my soup with a screwdrive

Re: Using filepath method to identify an .html page

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 11:36:31 -0700, Michael Torrie wrote: > I'm sorry you are getting so frustrated. There's obviously a language > barrier here, I don't think there is. The OP's posts have been written in excellent English. I think we've been well and truly trolled, by somebody who even uses

Re: Using filepath method to identify an .html page

2013-01-22 Thread Michael Torrie
On 01/22/2013 04:40 PM, Steven D'Aprano wrote: > On Tue, 22 Jan 2013 11:36:31 -0700, Michael Torrie wrote: > >> I'm sorry you are getting so frustrated. There's obviously a language >> barrier here, > > I don't think there is. The OP's posts have been written in excellent > English. Well, his

Re: Else statement executing when it shouldnt

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 16:48:35 +0100, Thomas Boell wrote: > On Wed, 23 Jan 2013 02:42:27 +1100 > Chris Angelico wrote: > >> On Wed, Jan 23, 2013 at 2:39 AM, Thomas Boell >> wrote: >> > Huh?! I would have expected all your examples to raise a SyntaxError >> > or IndentationError. Why don't they? I

Re: Using filepath method to identify an .html page

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 09:33:00 -0800, rusi wrote: > On Jan 22, 8:59 pm, Ferrous Cranus wrote: >> I just need a way to CONVERT a string(absolute path) to a 4-digit >> unique number with INT!!! That's all i want!! But i cannot make it work >> :( > > I just need a way to eat my soup with a screwdrive

Re: Using filepath method to identify an .html page

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 10:07:21 -0800, Ferrous Cranus wrote: > No, because i DO NOT WANT to store LOTS OF BIGS absolute paths in the > database. They are not big. They are tiny. Please stop being too arrogant to listen to advice from people who have been programming for years or decades. -- St

Re: Using filepath method to identify an .html page

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 11:36:31 -0700, Michael Torrie wrote: > I'm sorry you are getting so frustrated. There's obviously a language > barrier here, I don't think there is. The OP's posts have been written in excellent English. I think we've been well and truly trolled, by somebody who even uses

Re: Using filepath method to identify an .html page

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 11:36:31 -0700, Michael Torrie wrote: > I'm sorry you are getting so frustrated. There's obviously a language > barrier here, I don't think there is. The OP's posts have been written in excellent English. I think we've been well and truly trolled, by somebody who even uses

Re: Using filepath method to identify an .html page

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 11:36:31 -0700, Michael Torrie wrote: > I'm sorry you are getting so frustrated. There's obviously a language > barrier here, I don't think there is. The OP's posts have been written in excellent English. I think we've been well and truly trolled, by somebody who even uses

Re: Using filepath method to identify an .html page

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 11:36:31 -0700, Michael Torrie wrote: > I'm sorry you are getting so frustrated. There's obviously a language > barrier here, I don't think there is. The OP's posts have been written in excellent English. I think we've been well and truly trolled, by somebody who even uses

Re: Using filepath method to identify an .html page

2013-01-22 Thread Steven D'Aprano
On Tue, 22 Jan 2013 11:36:31 -0700, Michael Torrie wrote: > I'm sorry you are getting so frustrated. There's obviously a language > barrier here, I don't think there is. The OP's posts have been written in excellent English. I think we've been well and truly trolled, by somebody who even uses

  1   2   >