Re: addressof object with id()
On Sat, 23 Mar 2013 19:37:35 -0500, Fabian von Romberg wrote: > I have a single questions regarding id() built-in function. > > example 1: > > var1 = "some string" > var2 = "some string" > > if use the id() function on both, it returns exactly the same address. I'm assuming that you used something other than "some string" for your tests (e.g. something without a space). Python *may* intern strings. The CPython implementation *does* intern strings which are valid identifiers (a sequence of letters, digits and underscores not starting with a digit), in order to optimise attribute lookups. FWIW, it also does this for integers between -5 <= n <= 256: > var1 = 256 > var2 = 255 + 1 > id(var1) 21499520 > id(var2) 21499520 > var3 = var1 + 1 > var4 = 257 > id(var3) 21541752 > id(var4) 21541584 In this case, it just saves on memory. More generally, an implementation *may* intern any immutable value, although it's not guaranteed to do so for anything except (IIRC) False, True and None. -- http://mail.python.org/mailman/listinfo/python-list
Re: Separate Rows in reader
On 03/24/2013 01:20 AM, Jiewei Huang wrote: Hi all, Currently create a simple text-based database of information about people I have a csv file which consist of 3 rows , row 1 2 and 3 is as such: Name AddressTelephone Birthday John Konon Ministry of Moon Walks 4567882 27-Feb Stacy Kisha Ministry of Man Power 1234567 17-Jan My codes are : import csv original = file('friends.csv', 'rU') reader = csv.reader(original) for row in reader: print row and the output is : ['Name', ' Address', 'Telephone', 'Birthday'] ['John Konon', 'Ministry of Moon Walks', '4567882', '27-Feb'] ['Stacy Kisha', 'Ministry of Man Power', '1234567', '17-Jan'] But i wanted to make it [('John Cleese', 'Ministry of Silly Walks', '421', '27-Feb'), ( 'Stacy Kisha', 'Ministry of Man Power', '1234567', 17-Jan')] can someone show me guidance to this issue Thanks all There are at least 3 differences to the printouts. Which difference are you concerned with? 1) Moon --> Silly 2) square and round brackets in slightly different places 3) row 0 suppressed Explain which one, or specify a fourth, and also what you have tried to address the question. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Separate Rows in reader
Hi all, Currently create a simple text-based database of information about people I have a csv file which consist of 3 rows , row 1 2 and 3 is as such: Name AddressTelephone Birthday John Konon Ministry of Moon Walks 4567882 27-Feb Stacy Kisha Ministry of Man Power 1234567 17-Jan My codes are : import csv original = file('friends.csv', 'rU') reader = csv.reader(original) for row in reader: print row and the output is : ['Name', ' Address', 'Telephone', 'Birthday'] ['John Konon', 'Ministry of Moon Walks', '4567882', '27-Feb'] ['Stacy Kisha', 'Ministry of Man Power', '1234567', '17-Jan'] But i wanted to make it [('John Cleese', 'Ministry of Silly Walks', '421', '27-Feb'), ( 'Stacy Kisha', 'Ministry of Man Power', '1234567', 17-Jan')] can someone show me guidance to this issue Thanks all -- http://mail.python.org/mailman/listinfo/python-list
Re: addressof object with id()
On Mar 24, 8:33 am, Chris Angelico wrote: > On Sun, Mar 24, 2013 at 1:19 PM, Roy Smith wrote: > > In article <514e5f1f$0$30001$c3e8da3$54964...@news.astraweb.com>, > > Steven D'Aprano wrote: > > >> Those who don't do serious floating point work hate NANs > > > This kind of thing doesn't just come up in floating point work. SQL > > folks have much the same issue with NULL. > > Oh, NULL is easy to deal with. It's the magic value that isn't a > value, except when it's a value, because it's the only value that you > can use when you need a value that's not a value. Of course, sometimes > it breaks that rule. > > ChrisA Which is an elaboration of NAN: (A number that is) Not A Number. All these are different variants of ⊥ (or _|_ if that does not print) in denotational semantics. That is when a function is partial, we make it artificially total by adding an explicit bogus value to the range and mapping all undefined points to that point. The problem is that when this is carried over from partial functions to infinite program loops, it can never work (in full generality) because loops are not detectable. -- http://mail.python.org/mailman/listinfo/python-list
Re: addressof object with id()
On Sun, Mar 24, 2013 at 1:19 PM, Roy Smith wrote: > In article <514e5f1f$0$30001$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> Those who don't do serious floating point work hate NANs > > This kind of thing doesn't just come up in floating point work. SQL > folks have much the same issue with NULL. Oh, NULL is easy to deal with. It's the magic value that isn't a value, except when it's a value, because it's the only value that you can use when you need a value that's not a value. Of course, sometimes it breaks that rule. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: addressof object with id()
In article <514e5f1f$0$30001$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Those who don't do serious floating point work hate NANs This kind of thing doesn't just come up in floating point work. SQL folks have much the same issue with NULL. -- http://mail.python.org/mailman/listinfo/python-list
Re: addressof object with id()
In article <514e5e71$0$30001$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > As far as I know, there is no Python implementation that automatically > interns strings which are not valid identifiers. "some string" is not a > valid identifier, due to the space. I stand corrected. And somewhat humbled. -- http://mail.python.org/mailman/listinfo/python-list
Re: addressof object with id()
On Sun, 24 Mar 2013 11:56:50 +1100, Chris Angelico wrote: > On Sun, Mar 24, 2013 at 11:49 AM, Dave Angel wrote: >> You can assume that if the id's are equal, the objects are equal. But >> you can't assume the inverse or the converse. > > To be more specific: If the ids are equal, the objects are identical. > Doesn't mean they'll compare equal - for instance, float("nan") isn't > equal to itself. But for most situations, you can assume that identical > objects compare equal. Also note that containers are permitted to assume reflexivity, that is, that x == x. That sometimes means that they don't play well with non- reflexive values such as NANs. e.g. x = [float('nan')] x == x even though x[0] != x[0] This has been discussed repeatedly on the Python-Dev mailing list, and the consensus is that there is no real consensus. Those who don't do serious floating point work hate NANs, those who do are split between loving NANs and merely tolerating them because the IEEE standard requires them, but pretty much everyone agrees that containers should be free to assume identity implies equality. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: addressof object with id()
On Sat, 23 Mar 2013 21:00:07 -0400, Roy Smith wrote: > In article , > Fabian von Romberg wrote: > >> Hi, >> >> I have a single questions regarding id() built-in function. >> >> example 1: >> >> var1 = "some string" >> var2 = "some string" >> >> if use the id() function on both, it returns exactly the same address. > > Yup. Nope. Did you actually try it? As far as I know, there is no Python implementation that automatically interns strings which are not valid identifiers. "some string" is not a valid identifier, due to the space. [...] > which is, of course, the result I expected. Then I tried: > z = "f" + "oo" id(z) > 3810944 > > which actually surprised me. I had thought interning only affected > string literals, but apparently it works for all strings! This works > too: > a = "b" + "ar" b = "ba" + "r" id(a) > 3810152 id(b) > 3810152 You're not actually testing what you think you're testing. In Cpython, which I assume you are using, there is a keyhole optimizer that runs when code is compiled to byte-code, and it folds some constant expressions like `a = "b" + "ar"` to `a = "bar"`. To defeat the keyhole optimizer, you need something like this: a = "bar" b = "".join(["b", "a", "r"]) although of course a sufficiently smart keyhole optimizer could recognise that as a constant as well. This, on the other hand, will defeat it: b = str("ba") + str("r") because the keyhole optimizer cannot tell whether str() is still the built-in function or has been replaced by something else. > but, again, none of this is guaranteed. Correct. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: addressof object with id()
On Sat, 23 Mar 2013 19:37:35 -0500, Fabian von Romberg wrote: > Hi, > > I have a single questions regarding id() built-in function. > > example 1: > > var1 = "some string" > var2 = "some string" > > if use the id() function on both, it returns exactly the same address. The id() function does not return an address. Scrub that from your mind. See below for further details. In any case, when I try the above, I do *not* get the same ID. py> var1 = "some string" py> var2 = "some string" py> id(var1), id(var2) (3082752384L, 3082752960L) I get two distinct IDs. > example 2: > > data = "some string" > var1 = data > var2 = data In this case, id(var1) and id(var2) is *guaranteed* to return the same value, because both names are bound to the same object. The first line creates a string object and binds it to the name "data". The second line binds the same object to the name "var1", and the third line does the same to the name "var2". So now you have three names all referring to the same object. Since all three names refer to the same object, it doesn't matter whether you call id(data), id(var1) or id(var2), they return the same ID. Objects in Python are like people -- they can have more than one name, or no name at all. Depending on who is doing the talking, all of the following could refer to the same person: "Barrack" "Obama" "Dad" "Son" "Mr. President" "POTUS" "Renegade" > if use the id() function on var1 and var2, it returns exactly the same > address. The id() function does not return an address. It returns an arbitrary identification number, an ID. In Jython, IDs start at 1, and are never re- used. In CPython, IDs look like addresses[1], and may be re-used. The only promises that Python makes about IDs are: - they are integers; - they are constant for the life-time of the object; - they are unique for the life-time of the object. That means that they *may* or *may not* be re-used. Jython does not re- use them, CPython does. Python does not make many promises about object identity. Creating a new object using a literal expression may or may not create a new object. Python makes no promises either way. For example: py> a = 42 py> b = 42 py> id(a) == id(b) # a and b are the same object True but: py> a = 42 py> b = 42 py> id(a) == id(b) # a and b are different objects False but: py> x = id(42) py> y = id(42) py> x == y # x and y get the same ID True However all of these examples are implementation dependent and may vary according to the Python implementation and version. In particular, the third example is specific to CPython. In Jython, for example, the IDs will be unequal. id() is one of the most pointless functions in Python. There is almost never any need to care about the id of an object. I wish that it were moved into the inspect module instead of a built-in function, because in practice id() is only useful for confusing beginners. [1] They look like addresses because the CPython implementation uses the address of the object, as returned by the C compiler, as the ID. But since there is no way to dereference an id, or lookup the object found at an id, it is not an address. It merely has the same numeric value as what the C compiler sees as the address. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: addressof object with id()
On Sun, Mar 24, 2013 at 12:00 PM, Roy Smith wrote: > I had thought interning only affected > string literals, but apparently it works for all strings! This works > too: > a = "b" + "ar" b = "ba" + "r" id(a) > 3810152 id(b) > 3810152 > > but, again, none of this is guaranteed. No, what that proves is that concatenation of literals is treated as a literal. >>> a="foo" >>> b="fo" >>> b+="o" >>> id(a) 14870112 >>> id(b) 15985760 >>> c="fo"+"o" >>> id(c) 14870112 However, you can of course force the matter. >>> a=sys.intern(a) >>> b=sys.intern(b) >>> c=sys.intern(c) >>> id(a),id(b),id(c) (14870112, 14870112, 14870112) (In Python 2, use intern() rather than sys.intern().) It seems that in CPython 3.3.0 on Windows 32-bit (and yes, I do need to be that specific, though this probably applies to a broad range of CPython versions), string literals are interned. But that's an implementation detail. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: addressof object with id()
In article , Chris Angelico wrote: > On Sun, Mar 24, 2013 at 11:49 AM, Dave Angel wrote: > > You can assume that if the id's are equal, the objects are equal. But you > > can't assume the inverse or the converse. > > To be more specific: If the ids are equal, the objects are identical. > Doesn't mean they'll compare equal - for instance, float("nan") isn't > equal to itself. But for most situations, you can assume that > identical objects compare equal. >>> n = float("nan") # No real surprise here >>> n == n False # But this is kind of weird >>> [n] == [n] True In fact, that's actually a bug (or at least, contrary to the documented behavior). The docs (http://docs.python.org/2/library/stdtypes.html) say: > In particular, tuples and lists are compared lexicographically by comparing > corresponding elements. This means that to compare equal, every element must > compare equal and the two sequences must be of the same type and have the > same length and that's not what's happening here: >>> l1 = [n] >>> l2 = [n] >>> l1 == l2 True >>> l1[0] == l2[0] False -- http://mail.python.org/mailman/listinfo/python-list
Re: addressof object with id()
In article , Fabian von Romberg wrote: > Hi, > > I have a single questions regarding id() built-in function. > > example 1: > > var1 = "some string" > var2 = "some string" > > if use the id() function on both, it returns exactly the same address. Yup. This is because (in some implementations, but not guaranteed), Python interns strings. That means, when you create a string literal (i.e. something in quotes), the system looks to see if it's seen that exact same string before and if so, gives you a reference to the same string in memory, instead of creating a new one. Also, be careful about saying things like, "the id() function [...] returns [an] address. It's only in some implementations (and, again, not guaranteed), that id() returns the address of an object. All the docs say is, "an integer (or long integer) which is guaranteed to be unique and constant for this object during its lifetime". An implementation is free to number objects consecutively from 1, or from 23000, or pick random numbers, anything else it wants, as long as it meets that requirement. BTW, I tried this: >>> x = "foo" >>> y = "foo" >>> id(x) 3810944 >>> id(y) 3810944 which is, of course, the result I expected. Then I tried: >>> z = "f" + "oo" >>> id(z) 3810944 which actually surprised me. I had thought interning only affected string literals, but apparently it works for all strings! This works too: >>> a = "b" + "ar" >>> b = "ba" + "r" >>> id(a) 3810152 >>> id(b) 3810152 but, again, none of this is guaranteed. -- http://mail.python.org/mailman/listinfo/python-list
Re: addressof object with id()
On Sun, Mar 24, 2013 at 11:49 AM, Dave Angel wrote: > You can assume that if the id's are equal, the objects are equal. But you > can't assume the inverse or the converse. To be more specific: If the ids are equal, the objects are identical. Doesn't mean they'll compare equal - for instance, float("nan") isn't equal to itself. But for most situations, you can assume that identical objects compare equal. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: addressof object with id()
On 03/23/2013 08:37 PM, Fabian von Romberg wrote: Hi, I have a single questions regarding id() built-in function. example 1: var1 = "some string" var2 = "some string" if use the id() function on both, it returns exactly the same address. example 2: data = "some string" var1 = data var2 = data if use the id() function on var1 and var2, it returns exactly the same address. can anyone explain me please why does this happens? Is this correct? The Python system may decide to optimize new objects by reusing old ones, IF the type is immutable. This ends up saving a good bit of space. Three places that come to mind are strings, small ints, and booleans. In fact for booleans, it's required behavior. There is exactly one True object, and one False object. You can assume that if the id's are equal, the objects are equal. But you can't assume the inverse or the converse. So it also turns out to save some time. When two objects are being compared for equal, and it turns out they have the same id, there's no need to actually look at the contents. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
addressof object with id()
Hi, I have a single questions regarding id() built-in function. example 1: var1 = "some string" var2 = "some string" if use the id() function on both, it returns exactly the same address. example 2: data = "some string" var1 = data var2 = data if use the id() function on var1 and var2, it returns exactly the same address. can anyone explain me please why does this happens? Is this correct? Thanks in advance and regards, Fabian -- http://mail.python.org/mailman/listinfo/python-list
Re: how does the % work?
On Sat, 23 Mar 2013 09:57:48 -0600, Michael Torrie wrote: > On 03/23/2013 01:38 AM, Steven D'Aprano wrote: >> Just to add confusion, the two lines are exactly the same in Python 2, >> where Print is not a function! > > Perhaps this is a good reason use the slightly more complicated but > easier to get right format method. > > print ("{0}, {1}, {2}".format(1,2,3)) Misplaced parentheses are possible either way. print ("{0}, {1}, {2}".format(1,2,3)) print ("{0}, {1}, {2}").format(1,2,3) > And it's worth noting that using the string formatter or the old % > operator on a string works anywhere where there're strings, not just in > the print function. Very true. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: SOAPpy.Types.faultType: Cannot use object of type stdClass as array
On Sun, Mar 24, 2013 at 6:38 AM, Tamer Higazi wrote: > Chris! > I did what you said before in several ways. > > The last way was putting the user and password directly into the dict as > parameter ALWAYS ends up telling me, that I cannot use object of > standard type class as ARRAY > > I did it this time with suds. So packaging issue is now out of scope, > and always the same headache. > > > now tell me what this error might tell me: > > > suds.WebFault: Server raised fault: 'Cannot use object of type stdClass > as array' So it's the same error this way, too. That error came back from the server, and is being quoted verbatim. That means that, ultimately, the problem is in the XML blob that you're sending it; the trick is to figure out what exactly the server isn't happy with. (Aside: The server is at least partly at fault here. It should be giving more useful error messages. But I'm assuming you don't have any control over the server.) I tried the reference PHP implementation off the web site, and it's coming back with 500 Internal Server Error with body of text/html, which is clearly buggy documentation. When I change it to use the WSDL you're using, I can actually get something plausible out of it. Modified PHP code: https://kasapi.kasserver.com/soap/wsdl/KasAuth.wsdl'; //$WSDL_API = 'https://kasserver.com/schnittstelle/soap/wsdl/KasApi.wsdl'; // Logindaten $kas_user = 'w001234'; // KAS-Logon $kas_pass = 'xxx'; // KAS-Passwort $session_lifetime = 1800; // Gültigkeit des Tokens in Sek. bis zur neuen Authentifizierung $session_update_lifetime = 'Y'; // Soll bei jeder Aktion die Sessionlifetime wieder auf den // Wert in "$session_lifetime" gesetzt werden? ('Y' / 'N') try { $SoapLogon = new SoapClient($WSDL_AUTH,["trace"=>1]); // url zur wsdl - Datei $CredentialToken = $SoapLogon->KasAuth( array('KasUser' => $kas_user, 'KasAuthType' => 'sha1', 'KasPassword' => sha1($kas_pass), 'SessionLifeTime' => $session_lifetime, 'SessionUpdateLifeTime' => $session_update_lifetime ) ); } // Fehler abfangen und ausgeben catch (SoapFault $fault) { echo "Request:\n".$SoapLogon->__getLastRequestHeaders()."\n".$SoapLogon->__getLastRequest()."\n"; echo "Response:\n".$SoapLogon->__getLastResponseHeaders()."\n".$SoapLogon->__getLastResponse()."\n"; trigger_error("Fehlernummer: {$fault->faultcode}, Fehlermeldung: {$fault->faultstring}, Verursacher: {$fault->faultactor}, Details: {$fault->detail}", E_USER_ERROR); } (Another aside: Until I added the two echo lines, this had a try/catch that simply triggered a fatal error. This is pointless. Just let the error happen!) Here's the packet the PHP code sends: http://schemas.xmlsoap.org/soap/envelope/"; xmlns:ns1="urn:xmethodsKasApiAuthentication" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:ns2="http://xml.apache.org/xml-soap"; xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"; SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>KasUserw001234KasAuthTypesha1KasPassword2db6d21d365f544f7ca3bcfb443ac96898a7a069SessionLifeTime1800SessionUpdateLifeTimeY Here's what your original Python version sends, lifted via tcpdump as I'm not sufficiently familiar with soappy to get a full packet dump out of it: http://schemas.xmlsoap.org/soap/encoding/"; xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"; xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsd="http://www.w3.org/1999/XMLSchema"; > Y sha1 1800 login 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8 And here's what your latest Python sends, lifted the same way for the same reason regarding suds: http://www.w3.org/2001/XMLSchema"; xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:ns0="urn:xmethodsKasApiAuthentication" xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:ns4="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>Ysha11800userlogin45f106ef4d5161e7aa38cf6c07f25748b6ca The PHP version comes back with a fault string "kas_password_incorrect", which is what I would expect. The Python ones both show the PHP crash you described. I'm seeing quite a few differences between the three; figuring out what's the cause of the crash will be a matter of fiddling until you discover it. I would recommend, at least for testing, bypassing the whole SOAP library layer and putting XML data straight into HTTP requests. And maybe you'll find t
Re: SOAPpy.Types.faultType: Cannot use object of type stdClass as array
Chris! I did what you said before in several ways. The last way was putting the user and password directly into the dict as parameter ALWAYS ends up telling me, that I cannot use object of standard type class as ARRAY I did it this time with suds. So packaging issue is now out of scope, and always the same headache. now tell me what this error might tell me: suds.WebFault: Server raised fault: 'Cannot use object of type stdClass as array' File "/storage/PyProjects/toolsAPP/python/KASUpdate2.py", line 23, in KasObj = KASSystem() File "/storage/PyProjects/toolsAPP/python/KASUpdate2.py", line 20, in __init__ 'SessionUpdateLifeTime':'Y'}) File "/storage/PyENV/lin/toolsENV/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/client.py", line 542, in __call__ File "/storage/PyENV/lin/toolsENV/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/client.py", line 602, in invoke File "/storage/PyENV/lin/toolsENV/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/client.py", line 649, in send File "/storage/PyENV/lin/toolsENV/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/client.py", line 702, in failed File "/storage/PyENV/lin/toolsENV/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/bindings/binding.py", line 265, in get_fault and when I open the python files they hand me out only the error messages, which was sent back from Server! here is the code: import hashlib from suds.client import Client from suds import WebFault class KASSystem: def __init__(self): WSDL_AUTH = 'https://kasapi.kasserver.com/soap/wsdl/KasAuth.wsdl' WSDL_API = 'https://kasapi.kasserver.com/soap/wsdl/KasApi.wsdl' m = hashlib.sha1() m.update('userpass') SoapClient = Client(WSDL_AUTH) SoapClient.service.KasAuth({ 'KasUser':'userlogin', 'KasAuthType':'sha1', 'KasPassword':m.hexdigest(), 'SessionLifeTime':1800, 'SessionUpdateLifeTime':'Y'}) KasObj = KASSystem() Tamer Am 23.03.2013 16:03, schrieb Chris Angelico: > On Sun, Mar 24, 2013 at 12:33 AM, Tamer Higazi wrote: >> Hi Chris! >> thanks But I am about of going nuts I did everything according >> their sample: >> >> http://kasapi.kasserver.com/dokumentation/?open=soap > > Since I'm not fluent in German, I'm relying on Google Translate to > read of that page. (I didn't find an obvious English version of the > page, but maybe I just didn't look in the right place.) > > One thing I've found about the PHP SOAP library is that it seems to > behave quite oddly in some circumstances - my suspicion is the WSDL > file (eg when it's unable to load it). Try monitoring the actual > traffic - SOAP is XML carried over HTTP, so you should be able to just > snoop the TCP/IP socket (easiest way might be to switch in your own > server). See if you can spot a difference between the request that PHP > sends and the one your Python script sends. Fortunately you're not > moving megabytes of data around, here - it should be easy enough to > eyeball the requests and see what's different about them :) > > A tip, by the way: > > userpass = ['login','password'] > m = hashlib.sha1() > m.update(userpass[1]) > > userpass[1] = m.hexdigest() > loginData = {'user':userpass[0],'pass':userpass[1]} > > 'KasUser':loginData['user'], > 'KasPassword':loginData['pass'], > > You keep packaging and repackaging the credentials. I'm assuming you > won't actually have them hard-coded like that (if you do, I would > recommend hard-coding the SHA1 hash, rather than the password itself), > so I'll stick with the userpass list (or tuple, which would work > exactly the same way). > > password = hashlib.sha1(userpass[1]).hexdigest() > ... > 'KasUser':userpass[0], > 'KasPassword':password, > > Or even inline that completely (which is what I'd probably do). > There's no need to stuff it into a dictionary, only to pull it out > again. > > Also: A try/except that just prints out the error message usually > isn't helpful. Save yourself the trouble, at least during initial > testing - just let the exception terminate your script. You'll get all > the same information, plus the full traceback, and it's cost you > exactly zero development time :) Later on, you can add try/except if > you need to do something other than terminate, but often that "later > on" never even happens. > > ChrisA > -- http://mail.python.org/mailman/listinfo/python-list
Re:
On Sat, Mar 23, 2013 at 11:33 AM, Chris Angelico wrote: > On Sun, Mar 24, 2013 at 2:22 AM, Yann Manuel > wrote: > > Dear Mr/Mrs, > > > > I'm reading this book called dive into python 3, and the author does not > > describe everything, but he gives a link to a blog: > > (http://adam.gomaa.us/blog/2008/aug/11/t ... y-builtin/). > > The blog is gone and i cant find it. Does anyone knows where i can find > the > > information of this blog or at least something similar to it? > > The blog is called the python property built in, by adam gomaa > > Sincerly yours, > I just googled him. He has several repositories and also a facebook page. Why not see if you can contact him directly > -- > http://mail.python.org/mailman/listinfo/python-list > -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
Re: LiClipse
On Sat, Mar 23, 2013 at 2:27 PM, rusi wrote: > On Mar 23, 4:11 pm, Fabio Zadrozny wrote: > > On Sat, Mar 23, 2013 at 12:38 AM, rusi wrote: > > > > > > ie Eclipse-4 claims to have made plugin development (for new custom > > > languages) easier. > > > What is the relation of liclipse to eclipse 3<->4 plugin architecture? > > > > Well, it may have become a bit easier (with dltk and xtext), but it's > still > > far from trivial (you still have to know at least java, how plugins work, > > eclipse internals, creating a grammar, etc.). > > I still have one (quite general) question: > When eclipse 'does' pydev, is it mostly in java or in python? > > Using python's native parser etc makes the analysis more reliable at > the cost of more fragile, non-portable(?) etc plumbing between java > and python. > > Whereas rewriting python's parsing etc in java, makes the basic > architecture easier but will always keep you behind target when say > python changes/adds to its syntax/feature set etc. > Parsing in PyDev is done at java (so, yes, I have to update it when Python itself goes forward). Still, note that even if I was in Python and could use the Python parser, I don't think that using the internal Python parser would be a good choice (because it ends up being too fragile for me -- i.e.: if the IDE is done using Python 2.x it wouldn't be able to analyze a Python 3 codebase -- unless it spawned scripts based on the configured Python you're developing against, but things as a proper code analysis would prove very difficult to do that way). Also, the feature set from the PyDev grammar is different from the Python grammar: For example: - it has to be fault tolerant (because you'll still want to see the outline and get code completion even if you don't have the complete file correct) - it may need to store more information in case a pretty-printing is needed later on (so, the Python grammar can get something as "a = (1)" and remove the parenthesis as they don't make part of the AST, as that's the same as "a = 1" but in case you were pretty-printing the AST you may not want to throw that away). > > Which do you choose? And are the new facilities in Juno easier for > cross-language feature-sets? > As for easier cross-language feature sets, not sure what exactly are you referring to... (but I don't think Eclipse 4 itself changed much from the existing status quo... it's may difference in the programming model is on the dependency injection, so some APIs are cleaner now -- besides the UI changes). Cheers, Fabio > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: LiClipse
On Mar 23, 4:11 pm, Fabio Zadrozny wrote: > On Sat, Mar 23, 2013 at 12:38 AM, rusi wrote: > > > > ie Eclipse-4 claims to have made plugin development (for new custom > > languages) easier. > > What is the relation of liclipse to eclipse 3<->4 plugin architecture? > > Well, it may have become a bit easier (with dltk and xtext), but it's still > far from trivial (you still have to know at least java, how plugins work, > eclipse internals, creating a grammar, etc.). I still have one (quite general) question: When eclipse 'does' pydev, is it mostly in java or in python? Using python's native parser etc makes the analysis more reliable at the cost of more fragile, non-portable(?) etc plumbing between java and python. Whereas rewriting python's parsing etc in java, makes the basic architecture easier but will always keep you behind target when say python changes/adds to its syntax/feature set etc. Which do you choose? And are the new facilities in Juno easier for cross-language feature-sets? -- http://mail.python.org/mailman/listinfo/python-list
Re: how does the % work?
thank you all! Il 23/03/2013 8.38, Steven D'Aprano ha scritto: On Fri, 22 Mar 2013 21:29:48 -0700, Tim Roberts wrote: leonardo selmi wrote: i wrote this example : name = raw_input("What is your name?") quest = raw_input("What is your quest?") color = raw_input("What is your favorite color?") print """Ah, so your name is %s, your quest is %s, and your favorite color is %s.""" % (name, quest, color) No, you didn't. You wrote: print('''Ah, so your name is %s, your quest is %s, and your favorite color is %s.''') % (name, quest, color) The difference between those two statements may not be entirely clear to someone not experienced in reading code carefully. Consider the difference between: print(a % b) print(a) % b In the first example, the round brackets group the "a % b", which is calculated first, then printed. In the second example, in Python 3, the "print(a)" is called first, which returns None, and then "None % b" is calculated, which raises an exception. Just to add confusion, the two lines are exactly the same in Python 2, where Print is not a function! You are using Python 3. In Python 3, "print" is a function that returns None. So, the error is exactly correct. To fix it, you need to have the % operator operate on the string, not on the result of the "print" function: print('''Ah, so your name is %s, your quest is %s, and your favorite color is %s.''' % (name, quest, color)) Exactly correct. -- http://mail.python.org/mailman/listinfo/python-list
Re: Required arguments in argparse: at least one of a group
I don't know about argparse, but if you use docopt (http://docopt.org/) then this is easy to do with something like: """Usage: finder.py --file --dir finder.py --pattern --dir finder.py --file --pattern --dir """ On 23 March 2013 16:04, Marco wrote: > Is there the possibility using the argparse module to group two or more > arguments in order to have at least one of them required? For instance, I > would like to have not an error only in the following cases: > > python finder.py --file myfile --dir mydir > python finder.py --pattern mypattern --dir mydir > python finder.py --file myfile --pattern mypattern --dir mydir > > where --dir is required, and --file _or_ --parser have to be specified. In > other words, I want the parser prints an error message just in this case: > > python finder.py --dir mydir > > Thanks in advance, Marco > -- > Marco > -- > http://mail.python.org/mailman/listinfo/python-list -- Robert K. Day robert@merton.oxon.org -- http://mail.python.org/mailman/listinfo/python-list
Re: "monty" < "python"
On 23/03/2013 09:24, jmfauth wrote: On 20 mar, 22:02, Tim Delaney wrote: On 21 March 2013 06:40, jmfauth wrote: [snip usual rant from jmf] It has been acknowledged as a real regression, but he keeps hijacking every thread where strings are mentioned to harp on about it. He has shown no inclination to attempt to *fix* the regression and is rapidly coming to be regarded as a troll by most participants in this list. - I can not help to fix it, because it is "unfixable". It is "unfixable", because this flexible string representation is wrong by design. jmf Of course it's fixable. All you need do is write a PEP clearing stating what is wrong with the implementation detailed in PEP393 and your own proposed design. I'm looking forward to reading this PEP. Note that going backwards to buggier unicode implementations that existed in Python prior to version 3.3 is simply not an option. -- Cheers. Mark Lawrence -- http://mail.python.org/mailman/listinfo/python-list
Welcome PythonScript: Python to Javascript translator in 350 lines of Python
Héllo, I'm happy to announce the immediate avaibility of PythonScript a Python -> Javascript translator written in Python. So far it works... Break it online @ http://apppyjs.appspot.com How it works ? Similarly to PyPy, it use a restricted version of Python called PythonJS. Along side this translator there is two other components PythonToPythonJS which translates (more) Python to PythonJS and a runtime library written in PythonJS that creates javascript objects to emulate classes, objects and methods. It's not compliant. Other Python in the browser solutions are written in Javascript (skulpt, brython) or both (pyjaco, pyjs) and are difficult to work with. This implementation is fully written in Python with small snippets of Javascript. Creating bindings is very easy, jQuery bindings are available. All the thing is not much tested. Also if you are interested in this topic, you might be interested by the avaibility of asm.js in Firefox nightly. asm.js is a subset of JS, that can be compiled by the browser, thus making solutions such as emscripten and PyPy with an asm.js backend more interesting. Cheers, Amirouche -- http://mail.python.org/mailman/listinfo/python-list
Re: "monty" < "python"
On 23/03/2013 09:23, jmfauth wrote: On 21 mar, 04:12, rusi wrote: On Mar 21, 12:40 am, jmfauth wrote: Courageous people can try to do something with the unicode collation algorithm (see unicode.org). Some time ago, for the fun, I wrote something (not perfect) with a reduced keys table (see unicode.org), only a keys subset for some scripts hold in memory. It works with Py32 and Py33. In an attempt to just see the performance and how it "can react", I did an horrible mistake, I forgot Py33 is now optimized for ascii user, it is no more unicode compliant and I stupidely tested/sorted lists of French words... Now lets take this piece by piece… "I did an horrible mistake" : I am sorry. Did you get bruised? Break some bones? And is 'h' a vowel in french? "I forgot Py33 is now optimized for ascii user" Ok. "it is no more unicode compliant" I asked earlier and I ask again -- What do you mean by (non)compliant? -- One aspect of Unicode (note the capitalized "U"). py32 timeit.repeat("'abc需'.find('a')") [0.27941279564856814, 0.26568106110789813, 0.265546366757917] timeit.repeat("'abcdef'.find('a')") [0.2891812867801491, 0.26698153112010914, 0.26738994644529157] py33 timeit.repeat("'abc需'.find('a')") [0.5941777382531654, 0.5829193385634426, 0.5519412133990045] timeit.repeat("'abcdef'.find('a')") [0.44333188136533863, 0.4232506078969891, 0.4225164843046514] jmf Are you saying that to be compliant a unicode implementation has to perform within given time bounds? -- Cheers. Mark Lawrence -- http://mail.python.org/mailman/listinfo/python-list
Required arguments in argparse: at least one of a group
Is there the possibility using the argparse module to group two or more arguments in order to have at least one of them required? For instance, I would like to have not an error only in the following cases: python finder.py --file myfile --dir mydir python finder.py --pattern mypattern --dir mydir python finder.py --file myfile --pattern mypattern --dir mydir where --dir is required, and --file _or_ --parser have to be specified. In other words, I want the parser prints an error message just in this case: python finder.py --dir mydir Thanks in advance, Marco -- Marco -- http://mail.python.org/mailman/listinfo/python-list
Re: how does the % work?
On 03/23/2013 01:38 AM, Steven D'Aprano wrote: > Just to add confusion, the two lines are exactly the same in Python 2, > where Print is not a function! Perhaps this is a good reason use the slightly more complicated but easier to get right format method. print ("{0}, {1}, {2}".format(1,2,3)) And it's worth noting that using the string formatter or the old % operator on a string works anywhere where there're strings, not just in the print function. b = "The answer was %d" % answer or b = "The answer was {0}".format(answer) On the topic of print, I can see the logic in print being a function now, but I have always preferred it as a print statement; it just looked cleaner. That was one of the things that initially attracted me to python. But the reality is print isn't used for much in real programs other than console debug messages. -- http://mail.python.org/mailman/listinfo/python-list
Re: LiClipse
On Sat, Mar 23, 2013 at 12:07 PM, Wanderer wrote: > On Saturday, March 23, 2013 7:11:10 AM UTC-4, Fabio Zadrozny wrote: > > On Sat, Mar 23, 2013 at 12:38 AM, rusi wrote: > > > > > > > > > > On Mar 23, 7:58 am, Fabio Zadrozny wrote: > > > > > > > > > Hello there, > > > > > > > > > > As I've proposed it, let me try to explain it a bit better (if you have > > > > > doubts, I should probably rephrase the proposal). > > > > > > > > > > There are 2 main targets there: keeping PyDev properly supported (which > > > > > hopefully doesn't need more explanation) and creating LiClipse. > > > > > > > > > > The idea for LiClipse is definitely not making a fork, but having an > easier > > > > > way to add a basic editor inside Eclipse (while developing PyDev, I do > get > > > > > many requests for adding support for editors related to Python, such as > > > > > Django templates, Mako, Restructured text, Cython, etc), so, this will > > > > > provide me with a basis to do that (and with the basis in place, the > idea > > > > > is having the possibility of creating an editor without knowledge of > > > > > Eclipse and in a very fast way -- current technologies for that such as > > > > > DLTK or XText aim much higher and are not trivial. I really want to > have a > > > > > way to have a basic editor inside Eclipse just specifying the language > very > > > > > 'loosely' -- say, something that'd take you 15-30 minutes and almost no > > > > > special knowledge of Eclipse internals -- and which would need more > > > > > knowledge of Eclipse internals only for more advanced stuff). > > > > > > > > > > As for the dark theme, it's something that annoys me a lot (so, I was > > > > > hoping it was also something interesting for other people -- right now, > > > > > it's not possible to have a professional dark theme in Eclipse, there > are > > > > > many loose ends -- so, for those that would like to work with a dark > theme > > > > > -- as myself -- it may be very annoying -- although yes, it may not be > > > > > applicable if you're happy with the current non-dark UI). > > > > > > > > > > As for distributions, yes, I plan to do an Eclipse distribution with > > > > > LiClipse / PyDev bundled -- Easy Eclipse is definitely not a solution > as it > > > > > is NOT supported (it has an ancient version of PyDev which only serves > to > > > > > confuse users and Eclipse.org does not have a Python version with > PyDev). > > > > > I'd hardly call that a fork thought (and it should be possible to > install > > > > > it as a separate plugin anyways, so, you can use the Eclipse you got > from > > > > > anywhere and just use the update site to get those plugins). > > > > > > > > > > Cheers, > > > > > > > > > > Fabio > > > > > > > > I am interested in the new eclipse plugin capabilities. > > > > Where does liclipse stand with respect to this? > > > > > > > > The idea is providing a way to add a language just by saying things like > keywords, elements (such as function or class -- if your language has > that), indenting words and it'll provide you an editor that has all the > common functions you'd expect, such as syntax highlighting, outline, > indenting, template completion, etc. So, in LiClipse, you shouldn't need to > create a plugin at this level, just one configuration file (which you > should be able to fill in 15-30 minutes). > > > > > > > > > > After that, if you want more things (such as code analysis or a semantic > aware code completion), then you'd have to go the route of actually > creating an Eclipse plugin. > > > > > > > > ie Eclipse-4 claims to have made plugin development (for new custom > > > > languages) easier. > > > > What is the relation of liclipse to eclipse 3<->4 plugin architecture? > > > > > > > > Well, it may have become a bit easier (with dltk and xtext), but it's > still far from trivial (you still have to know at least java, how plugins > work, eclipse internals, creating a grammar, etc.). > > > > > > > > > > The editors structure for LiClipse should work in both Eclipse 3 or 4, > although the theming enhancements will require Eclipse 4 (as it'll need > some features only available there). > > > > > > > > > > Cheers, > > > > > > Fabio > > Thanks for the response. Now I understand better what you're trying to do. > Eclipse can be something of a pain to get basic support to use new > languages. I never was able to get it to work with Vpascal. I would also > like the bundle, since I can't get the version in the lab to work like the > version on my desk. I've never been one for dark themes. My pet peeve is > the battle over negative numbers between PyDev and pep8.py. PyDev put the > space in and pep8.py gives me a warning. > I remember report like that, unfortunately, in the last months working at Appcelerator, it was very difficult to actually work on PyDev (as it wasn't a priority for them), but if the funding succeeds, I hope to fix those annoyances (formatting should definitely respect pep8). > Anyway, PyDev des
Re:
On Sun, Mar 24, 2013 at 2:22 AM, Yann Manuel wrote: > Dear Mr/Mrs, > > I'm reading this book called dive into python 3, and the author does not > describe everything, but he gives a link to a blog: > (http://adam.gomaa.us/blog/2008/aug/11/t ... y-builtin/). > The blog is gone and i cant find it. Does anyone knows where i can find the > information of this blog or at least something similar to it? > The blog is called the python property built in, by adam gomaa > Sincerly yours, Not a Python-specific answer, but this may help you: http://web.archive.org/web/20120718070139/http://adam.gomaa.us/blog/2008/aug/11/the-python-property-builtin/ The Wayback Machine has the blog archived. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
[no subject]
Dear Mr/Mrs, I'm reading this book called dive into python 3, and the author does not describe everything, but he gives a link to a blog: (http://adam.gomaa.us/blog/2008/aug/11/t ... y-builtin/). The blog is gone and i cant find it. Does anyone knows where i can find the information of this blog or at least something similar to it? The blog is called the python property built in, by adam gomaaSincerly yours, Yann Manuel from Holland.-- http://mail.python.org/mailman/listinfo/python-list
Re: LiClipse
On Saturday, March 23, 2013 7:11:10 AM UTC-4, Fabio Zadrozny wrote: > On Sat, Mar 23, 2013 at 12:38 AM, rusi wrote: > > > > > On Mar 23, 7:58 am, Fabio Zadrozny wrote: > > > > > Hello there, > > > > > > As I've proposed it, let me try to explain it a bit better (if you have > > > doubts, I should probably rephrase the proposal). > > > > > > There are 2 main targets there: keeping PyDev properly supported (which > > > hopefully doesn't need more explanation) and creating LiClipse. > > > > > > The idea for LiClipse is definitely not making a fork, but having an easier > > > way to add a basic editor inside Eclipse (while developing PyDev, I do get > > > many requests for adding support for editors related to Python, such as > > > Django templates, Mako, Restructured text, Cython, etc), so, this will > > > provide me with a basis to do that (and with the basis in place, the idea > > > is having the possibility of creating an editor without knowledge of > > > Eclipse and in a very fast way -- current technologies for that such as > > > DLTK or XText aim much higher and are not trivial. I really want to have a > > > way to have a basic editor inside Eclipse just specifying the language very > > > 'loosely' -- say, something that'd take you 15-30 minutes and almost no > > > special knowledge of Eclipse internals -- and which would need more > > > knowledge of Eclipse internals only for more advanced stuff). > > > > > > As for the dark theme, it's something that annoys me a lot (so, I was > > > hoping it was also something interesting for other people -- right now, > > > it's not possible to have a professional dark theme in Eclipse, there are > > > many loose ends -- so, for those that would like to work with a dark theme > > > -- as myself -- it may be very annoying -- although yes, it may not be > > > applicable if you're happy with the current non-dark UI). > > > > > > As for distributions, yes, I plan to do an Eclipse distribution with > > > LiClipse / PyDev bundled -- Easy Eclipse is definitely not a solution as it > > > is NOT supported (it has an ancient version of PyDev which only serves to > > > confuse users and Eclipse.org does not have a Python version with PyDev). > > > I'd hardly call that a fork thought (and it should be possible to install > > > it as a separate plugin anyways, so, you can use the Eclipse you got from > > > anywhere and just use the update site to get those plugins). > > > > > > Cheers, > > > > > > Fabio > > > > I am interested in the new eclipse plugin capabilities. > > Where does liclipse stand with respect to this? > > > > The idea is providing a way to add a language just by saying things like > keywords, elements (such as function or class -- if your language has that), > indenting words and it'll provide you an editor that has all the common > functions you'd expect, such as syntax highlighting, outline, indenting, > template completion, etc. So, in LiClipse, you shouldn't need to create a > plugin at this level, just one configuration file (which you should be able > to fill in 15-30 minutes). > > > > > After that, if you want more things (such as code analysis or a semantic > aware code completion), then you'd have to go the route of actually creating > an Eclipse plugin. > > > > ie Eclipse-4 claims to have made plugin development (for new custom > > languages) easier. > > What is the relation of liclipse to eclipse 3<->4 plugin architecture? > > > > Well, it may have become a bit easier (with dltk and xtext), but it's still > far from trivial (you still have to know at least java, how plugins work, > eclipse internals, creating a grammar, etc.). > > > > > The editors structure for LiClipse should work in both Eclipse 3 or 4, > although the theming enhancements will require Eclipse 4 (as it'll need some > features only available there). > > > > > Cheers, > > > Fabio Thanks for the response. Now I understand better what you're trying to do. Eclipse can be something of a pain to get basic support to use new languages. I never was able to get it to work with Vpascal. I would also like the bundle, since I can't get the version in the lab to work like the version on my desk. I've never been one for dark themes. My pet peeve is the battle over negative numbers between PyDev and pep8.py. PyDev put the space in and pep8.py gives me a warning. Anyway, PyDev deserves my support and thank you for all your hard work. -- http://mail.python.org/mailman/listinfo/python-list
Re: SOAPpy.Types.faultType: Cannot use object of type stdClass as array
On Sun, Mar 24, 2013 at 12:33 AM, Tamer Higazi wrote: > Hi Chris! > thanks But I am about of going nuts I did everything according > their sample: > > http://kasapi.kasserver.com/dokumentation/?open=soap Since I'm not fluent in German, I'm relying on Google Translate to read of that page. (I didn't find an obvious English version of the page, but maybe I just didn't look in the right place.) One thing I've found about the PHP SOAP library is that it seems to behave quite oddly in some circumstances - my suspicion is the WSDL file (eg when it's unable to load it). Try monitoring the actual traffic - SOAP is XML carried over HTTP, so you should be able to just snoop the TCP/IP socket (easiest way might be to switch in your own server). See if you can spot a difference between the request that PHP sends and the one your Python script sends. Fortunately you're not moving megabytes of data around, here - it should be easy enough to eyeball the requests and see what's different about them :) A tip, by the way: userpass = ['login','password'] m = hashlib.sha1() m.update(userpass[1]) userpass[1] = m.hexdigest() loginData = {'user':userpass[0],'pass':userpass[1]} 'KasUser':loginData['user'], 'KasPassword':loginData['pass'], You keep packaging and repackaging the credentials. I'm assuming you won't actually have them hard-coded like that (if you do, I would recommend hard-coding the SHA1 hash, rather than the password itself), so I'll stick with the userpass list (or tuple, which would work exactly the same way). password = hashlib.sha1(userpass[1]).hexdigest() ... 'KasUser':userpass[0], 'KasPassword':password, Or even inline that completely (which is what I'd probably do). There's no need to stuff it into a dictionary, only to pull it out again. Also: A try/except that just prints out the error message usually isn't helpful. Save yourself the trouble, at least during initial testing - just let the exception terminate your script. You'll get all the same information, plus the full traceback, and it's cost you exactly zero development time :) Later on, you can add try/except if you need to do something other than terminate, but often that "later on" never even happens. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: how to install indico software?
On 03/23/2013 10:38 AM, Mark Lawrence wrote: On 23/03/2013 14:15, Avnesh Shakya wrote: please tell me someone, how to install indico software? I have link-- http://indico-software.org/wiki/Admin/Installation0.98 http://indico-software.org/wiki/Releases/Indico0.99 is the link pointed to by: https://pypi.python.org/pypi/indico/ I'd start with pypi if I'm looking for the latest release. As for your other three problems, I have no idea. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: how to install indico software?
On 23/03/2013 14:15, Avnesh Shakya wrote: please tell me someone, how to install indico software? I have link-- http://indico-software.org/wiki/Admin/Installation0.98 but i have problem, i have no sites-available folder inside apache, i m using window 7, please help me.. Thanks in advance Please help us to help you. "i have a problem, i have no sites-available folder inside apache..." tells me that you have a problem with apache. Or have you tried "easy_install indico" from the command line and that's failed? Or are both these problems? Or neither? If you are specific about what you tried and what went wrong you are far more likely to get answers that will take you forward. -- Cheers. Mark Lawrence -- http://mail.python.org/mailman/listinfo/python-list
how to install indico software?
please tell me someone, how to install indico software? I have link-- http://indico-software.org/wiki/Admin/Installation0.98 but i have problem, i have no sites-available folder inside apache, i m using window 7, please help me.. Thanks in advance -- http://mail.python.org/mailman/listinfo/python-list
Re: SOAPpy.Types.faultType: Cannot use object of type stdClass as array
On 03/23/2013 09:33 AM, Tamer Higazi wrote: Hi Chris! thanks But I am about of going nuts I did everything according their sample: http://kasapi.kasserver.com/dokumentation/?open=soap and wanted to accomplish it in python! Isn't there an API on Python SOAPpy published somewhere? Wild guess, but perhaps the 1800 should have been '1800' php blurs the distinction between numbers and strings, and maybe the dict values are supposed to be all strings. If I pass a dict, I get the error telling me, this nonsense. What should I do?! I even tried it in "suds" instead of soappy, and I am not getting further. Tamer Am 21.03.2013 17:21, schrieb Chris Angelico: On Thu, Mar 21, 2013 at 6:06 AM, Tamer Higazi wrote: SOAPpy.Types.faultType: stdClass looks like a PHP error. Check out the server's requirements; perhaps you need to provide something as a list that you're providing as a dict, or something. I'd look at that loginData, for instance. ChrisA -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: SOAPpy.Types.faultType: Cannot use object of type stdClass as array
Hi Chris! thanks But I am about of going nuts I did everything according their sample: http://kasapi.kasserver.com/dokumentation/?open=soap and wanted to accomplish it in python! If I pass a dict, I get the error telling me, this nonsense. What should I do?! I even tried it in "suds" instead of soappy, and I am not getting further. Tamer Am 21.03.2013 17:21, schrieb Chris Angelico: > On Thu, Mar 21, 2013 at 6:06 AM, Tamer Higazi wrote: >> SOAPpy.Types.faultType: > type stdClass as array> > > stdClass looks like a PHP error. Check out the server's requirements; > perhaps you need to provide something as a list that you're providing > as a dict, or something. I'd look at that loginData, for instance. > > ChrisA > -- http://mail.python.org/mailman/listinfo/python-list
Re: Change in Python 3.3 with the treatment of sys.argv
On Sat, Mar 23, 2013 at 11:27 PM, Colin J. Williams wrote: > It seems that a change was made in the program between the 3.3 run and the > other runs. > > Each produces the same heading now. Yep, this is why the simple testcase is so valuable :) Check out http://sscce.org/ (which Steven also pointed you to) - note the points made under "Short". Glad it's solved, anyhow! ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Change in Python 3.3 with the treatment of sys.argv
On 22/03/2013 6:11 PM, Ethan Furman wrote: On 03/22/2013 02:57 PM, Colin J. Williams wrote: Below is an extract from some code to run on Python 2.7.3, 3.2.3 and 3.3.0 to compare speeds, both between versions and machines: if __name__ == '__main__': # Text string for initial test - Modify for your own machine or # delete it and and answer the input statement with your own machine # characteristics. sys.argv[1:]= ('Intel Pentium D CPU 3.0GHz 1.99 GB of RAM 221GB Disk Free space', ) main() def main(): if len(sys.argv) > 1: idMachine= ' '.join(sys.argv[1:]) ... oFile= open('FP' + now + '.log', 'w') oFile.writelines(idM + '\n' + sys.version + '\n') For 2.7, the result is: Intel_Pentium_D_CPU_3.0GHz_1.99_GB_of_RAM_221GB_Disk_Free_space 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] for 3.2, the result is: Intel_Pentium_D_CPU_3.0GHz_1.99_GB_of_RAM_221GB_Disk_Free_space 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] For 3.3, the result is: I_n_t_e_l___P_e_n_t_i_u_m___D___C_P_U___3_._0_G_H_z___1_._9_9___G_B___o_f___R_A_M___2_2_1_G_B___D_i_s_k___F_r_e_e___s_p_a_c_e 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] The full test result, for random matrices of increasing order is available here(http://web.ncf.ca/cjw/FP%20Summary%20over%20273-323-330.txt) First, this is what I get with 3.3: Python 3.3.0 (default, Sep 29 2012, 17:14:58) [GCC 4.7.2] on linux Type "help", "copyright", "credits" or "license" for more information. --> import sys --> sys.argv [''] --> sys.argv[1:] = ('this is a test!', ) --> sys.argv ['', 'this is a test!'] --> ' '.join(sys.argv[1:]) 'this is a test!' Second, your code doesn't show being joined by an underscore. -- ~Ethan~ APOLOGIES to those who responded. It seems that a change was made in the program between the 3.3 run and the other runs. Each produces the same heading now. Yes, I should have posted the test code. But, in these circumstances, there is no point in doing that. Colin W. Colin W. -- http://mail.python.org/mailman/listinfo/python-list
Re: LiClipse
On Sat, Mar 23, 2013 at 12:38 AM, rusi wrote: > On Mar 23, 7:58 am, Fabio Zadrozny wrote: > > Hello there, > > > > As I've proposed it, let me try to explain it a bit better (if you have > > doubts, I should probably rephrase the proposal). > > > > There are 2 main targets there: keeping PyDev properly supported (which > > hopefully doesn't need more explanation) and creating LiClipse. > > > > The idea for LiClipse is definitely not making a fork, but having an > easier > > way to add a basic editor inside Eclipse (while developing PyDev, I do > get > > many requests for adding support for editors related to Python, such as > > Django templates, Mako, Restructured text, Cython, etc), so, this will > > provide me with a basis to do that (and with the basis in place, the idea > > is having the possibility of creating an editor without knowledge of > > Eclipse and in a very fast way -- current technologies for that such as > > DLTK or XText aim much higher and are not trivial. I really want to have > a > > way to have a basic editor inside Eclipse just specifying the language > very > > 'loosely' -- say, something that'd take you 15-30 minutes and almost no > > special knowledge of Eclipse internals -- and which would need more > > knowledge of Eclipse internals only for more advanced stuff). > > > > As for the dark theme, it's something that annoys me a lot (so, I was > > hoping it was also something interesting for other people -- right now, > > it's not possible to have a professional dark theme in Eclipse, there are > > many loose ends -- so, for those that would like to work with a dark > theme > > -- as myself -- it may be very annoying -- although yes, it may not be > > applicable if you're happy with the current non-dark UI). > > > > As for distributions, yes, I plan to do an Eclipse distribution with > > LiClipse / PyDev bundled -- Easy Eclipse is definitely not a solution as > it > > is NOT supported (it has an ancient version of PyDev which only serves to > > confuse users and Eclipse.org does not have a Python version with PyDev). > > I'd hardly call that a fork thought (and it should be possible to install > > it as a separate plugin anyways, so, you can use the Eclipse you got from > > anywhere and just use the update site to get those plugins). > > > > Cheers, > > > > Fabio > > I am interested in the new eclipse plugin capabilities. > Where does liclipse stand with respect to this? > The idea is providing a way to add a language just by saying things like keywords, elements (such as function or class -- if your language has that), indenting words and it'll provide you an editor that has all the common functions you'd expect, such as syntax highlighting, outline, indenting, template completion, etc. So, in LiClipse, you shouldn't need to create a plugin at this level, just one configuration file (which you should be able to fill in 15-30 minutes). After that, if you want more things (such as code analysis or a semantic aware code completion), then you'd have to go the route of actually creating an Eclipse plugin. > ie Eclipse-4 claims to have made plugin development (for new custom > languages) easier. > What is the relation of liclipse to eclipse 3<->4 plugin architecture? > Well, it may have become a bit easier (with dltk and xtext), but it's still far from trivial (you still have to know at least java, how plugins work, eclipse internals, creating a grammar, etc.). The editors structure for LiClipse should work in both Eclipse 3 or 4, although the theming enhancements will require Eclipse 4 (as it'll need some features only available there). Cheers, Fabio -- http://mail.python.org/mailman/listinfo/python-list
Re: Change in Python 3.3 with the treatment of sys.argv
Colin J. Williams wrote: > No, the same program ran against each of the three versions. I assume > that 3.3 behaves differently. Please show some cooperation -- post actual code that shows the behaviour. Cut and paste instead of paraphrasing. Make it as small as you can. In your case that should be easy -- just rip out the actual benchmark and keep in only the tiny part that processes and prints sys.argv. -- http://mail.python.org/mailman/listinfo/python-list
Re: Change in Python 3.3 with the treatment of sys.argv
On 22/03/2013 6:11 PM, Ethan Furman wrote: On 03/22/2013 02:57 PM, Colin J. Williams wrote: Below is an extract from some code to run on Python 2.7.3, 3.2.3 and 3.3.0 to compare speeds, both between versions and machines: if __name__ == '__main__': # Text string for initial test - Modify for your own machine or # delete it and and answer the input statement with your own machine # characteristics. sys.argv[1:]= ('Intel Pentium D CPU 3.0GHz 1.99 GB of RAM 221GB Disk Free space', ) main() def main(): if len(sys.argv) > 1: idMachine= ' '.join(sys.argv[1:]) ... oFile= open('FP' + now + '.log', 'w') oFile.writelines(idM + '\n' + sys.version + '\n') For 2.7, the result is: Intel_Pentium_D_CPU_3.0GHz_1.99_GB_of_RAM_221GB_Disk_Free_space 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] for 3.2, the result is: Intel_Pentium_D_CPU_3.0GHz_1.99_GB_of_RAM_221GB_Disk_Free_space 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] For 3.3, the result is: I_n_t_e_l___P_e_n_t_i_u_m___D___C_P_U___3_._0_G_H_z___1_._9_9___G_B___o_f___R_A_M___2_2_1_G_B___D_i_s_k___F_r_e_e___s_p_a_c_e 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] The full test result, for random matrices of increasing order is available here(http://web.ncf.ca/cjw/FP%20Summary%20over%20273-323-330.txt) First, this is what I get with 3.3: Python 3.3.0 (default, Sep 29 2012, 17:14:58) [GCC 4.7.2] on linux Type "help", "copyright", "credits" or "license" for more information. --> import sys --> sys.argv [''] --> sys.argv[1:] = ('this is a test!', ) --> sys.argv ['', 'this is a test!'] --> ' '.join(sys.argv[1:]) 'this is a test!' Second, your code doesn't show being joined by an underscore. -- ~Ethan~ No, the same program ran against each of the three versions. I assume that 3.3 behaves differently. Colin W. -- http://mail.python.org/mailman/listinfo/python-list
Re: Communication between C++ server and Python app
I normally wouldn’t be able to find such great content as this on other sites. You have done a great job with each unique point made on this topic. Thank you for your hard work. - premium rate numbers Click Here premiumtelco -- View this message in context: http://python.6.n6.nabble.com/Communication-between-C-server-and-Python-app-tp4937660p5011431.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list
Re: "monty" < "python"
On Sat, Mar 23, 2013 at 8:45 PM, Chris Angelico wrote: > On Sat, Mar 23, 2013 at 8:23 PM, jmfauth wrote: >> One aspect of Unicode (note the capitalized "U"). >> >> [chomp yet another trivial microbenchmark] >> >> --- >> >> In French, depending of the word, a leading "h", behaves >> as a vowel or as a consonant. >> (From this -> this typical mistake) > > Huh? Did jmf and 8 Dihedral just team up to make a post? Ohh. That's in relation to "an horrible mistake". Though I still don't see what the parenthesis is saying. Pity, that. A merger between jmf and Dihedral would have been mutually beneficial. I'm sure it would be approved by the regulatory authorities, too. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: "monty" < "python"
On Sat, Mar 23, 2013 at 8:23 PM, jmfauth wrote: > One aspect of Unicode (note the capitalized "U"). > > [chomp yet another trivial microbenchmark] > > --- > > In French, depending of the word, a leading "h", behaves > as a vowel or as a consonant. > (From this -> this typical mistake) Huh? Did jmf and 8 Dihedral just team up to make a post? ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: "monty" < "python"
On 21 mar, 04:12, rusi wrote: > On Mar 21, 12:40 am, jmfauth wrote: > > > > > > Courageous people can try to do something with the unicode > > collation algorithm (see unicode.org). Some time ago, for the fun, > > I wrote something (not perfect) with a reduced keys table (see > > unicode.org), only a keys subset for some scripts hold in memory. > > > It works with Py32 and Py33. In an attempt to just see the > > performance and how it "can react", I did an horrible mistake, > > I forgot Py33 is now optimized for ascii user, it is no more > > unicode compliant and I stupidely tested/sorted lists of French > > words... > > Now lets take this piece by piece… > "I did an horrible mistake" : I am sorry. Did you get bruised? Break > some bones? And is 'h' a vowel in french? > "I forgot Py33 is now optimized for ascii user" Ok. > "it is no more unicode compliant" I asked earlier and I ask again -- > What do you mean by (non)compliant? -- One aspect of Unicode (note the capitalized "U"). py32 >>> timeit.repeat("'abc需'.find('a')") [0.27941279564856814, 0.26568106110789813, 0.265546366757917] >>> timeit.repeat("'abcdef'.find('a')") [0.2891812867801491, 0.26698153112010914, 0.26738994644529157] py33 timeit.repeat("'abc需'.find('a')") [0.5941777382531654, 0.5829193385634426, 0.5519412133990045] timeit.repeat("'abcdef'.find('a')") [0.44333188136533863, 0.4232506078969891, 0.4225164843046514] --- In French, depending of the word, a leading "h", behaves as a vowel or as a consonant. (From this -> this typical mistake) jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: "monty" < "python"
On 20 mar, 22:02, Tim Delaney wrote: > On 21 March 2013 06:40, jmfauth wrote: > > > > > [snip usual rant from jmf] > > > It has been acknowledged as a real regression, but he keeps hijacking every > thread where strings are mentioned to harp on about it. He has shown no > inclination to attempt to *fix* the regression and is rapidly coming to be > regarded as a troll by most participants in this list. > - I can not help to fix it, because it is "unfixable". It is "unfixable", because this flexible string representation is wrong by design. jmf -- http://mail.python.org/mailman/listinfo/python-list
Soappy: "Fault SOAP-ENV:Client: session_lifetime_syntax_incorrect"
Hi people! I try to access the service of my provider through SOAP, with the credentials I received from my provider once before. Hier ist der 33 lines of code: from SOAPpy import WSDL from SOAPpy.Errors import HTTPError as SoapHTTPError from SOAPpy.Types import faultType import hashlib class KASSystem: def __init__(self): WSDL_AUTH = 'https://kasapi.kasserver.com/soap/wsdl/KasAuth.wsdl' WSDL_API = 'https://kasapi.kasserver.com/soap/wsdl/KasApi.wsdl' userpass = ['mylogin','mypassword'] m = hashlib.sha1() m.update(userpass[1]) userpass[1] = m.hexdigest() loginData = {'user':userpass[0],'pass':userpass[1]} self.__SoapClient = WSDL.Proxy(WSDL_AUTH) try: self.__CredentialToken = self.__SoapClient.KasAuth('authAnfrage',{ 'KasUser':loginData['user'], 'KasAuthType':'sha1', 'KasPassword':loginData['pass'], 'SessionLifeTime':1800, 'SessionUpdateLifeTime':'Y'}) except (SoapHTTPError), e: print "Fehlermeldung:", e.code,e.msg KasObj = KASSystem() Here is the error message: Traceback (most recent call last): File "/storage/PyProjects/toolsAPP/KASUpdate.py", line 38, in KasObj = KASSystem() File "/storage/PyProjects/toolsAPP/KASUpdate.py", line 32, in __init__ 'SessionUpdateLifeTime':'Y'}) File "build/bdist.linux-x86_64/egg/SOAPpy/Client.py", line 540, in __call__ File "build/bdist.linux-x86_64/egg/SOAPpy/Client.py", line 562, in __r_call File "build/bdist.linux-x86_64/egg/SOAPpy/Client.py", line 475, in __call SOAPpy.Types.faultType: I really don't know what I did wrong for any help, I am grateful! Tamer -- http://mail.python.org/mailman/listinfo/python-list
Re: how does the % work?
On Saturday, March 23, 2013 2:38:23 AM UTC-5, Steven D'Aprano wrote: > On Fri, 22 Mar 2013 21:29:48 -0700, Tim Roberts wrote: > > print('''Ah, so your name is %s, your quest is %s, and your > > favorite color is %s.''') % (name, quest, color) > > The difference between those two statements may not be entirely clear to > someone not experienced in reading code carefully. I think the main problem with the code the OP presented is his attempt to stuff a long string literal into the print function. He should have separated the format string from the format operation: py> fmtstr = '''Ah, so your name is %s, your quest is %s, and your favorite color is %s.''' py> print(fmtstr%(1,2,3)) Ah, so your name is 1, your quest is 2, and your favorite color is 3. Sorry but i was too lazy to type out three string literal arguments, and instead, I reached for the low hanging syntactical sweetness of the integer peach. Mmm peaches! -- http://mail.python.org/mailman/listinfo/python-list
Re: how does the % work?
On Fri, 22 Mar 2013 21:29:48 -0700, Tim Roberts wrote: > leonardo selmi wrote: >> >>i wrote this example : >> >>name = raw_input("What is your name?") >>quest = raw_input("What is your quest?") >>color = raw_input("What is your favorite color?") >> >>print """Ah, so your name is %s, your quest is %s, and your favorite >>color is %s.""" % (name, quest, color) > > No, you didn't. You wrote: > > print('''Ah, so your name is %s, your quest is %s, and your > favorite color is %s.''') % (name, quest, color) The difference between those two statements may not be entirely clear to someone not experienced in reading code carefully. Consider the difference between: print(a % b) print(a) % b In the first example, the round brackets group the "a % b", which is calculated first, then printed. In the second example, in Python 3, the "print(a)" is called first, which returns None, and then "None % b" is calculated, which raises an exception. Just to add confusion, the two lines are exactly the same in Python 2, where Print is not a function! > You are using Python 3. In Python 3, "print" is a function that returns > None. So, the error is exactly correct. To fix it, you need to have > the % operator operate on the string, not on the result of the "print" > function: > > print('''Ah, so your name is %s, your quest is %s, and your > favorite color is %s.''' % (name, quest, color)) Exactly correct. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: how does the % work?
On Friday, March 22, 2013 11:29:48 PM UTC-5, Tim Roberts wrote: > You are using Python 3. In Python 3, "print" is a function that returns > None. So, the error is exactly correct. Wait a second... if he is in-fact using Python 3, then why did the call to a non-existent function named "raw_input" not throw an error first? Not to mention THREE calls to a non-existent function named "raw_input"! Hmm, my guess is that the python interpreter was too busy gossiping about that overblown sexual harassment BS at PyCon to even notice. -- http://mail.python.org/mailman/listinfo/python-list