Python: Code like a pythonista
http://python.net/~goodger/projects/pyc … ndout.html
Stumbled across that in a google search... some really useful things in there that I never knew. Hopefully it's useful to someone else.
James
phrakture wrote:
voonte wrote:
Quite interesting read, indeed.
But, I have never understood the
- 4 spaces per indentation level.
- No hard tabs.
argument.
It's a bikeshed. There are arguments for and against both sides - a coder's holy war. The only way to solve it is to say "screw you all, do it this way". Guido did just that.
Consistency is what really matters. I can show you a bunch of code, written in number of editors by a group of people who did not really care about consistency. Hopefully this is only C code, easy to fix with indent.
Similar Messages
-
Binary files in Python, code snippet in Java to Python
I'm trying to get data out of a game file (ITM/Baldurs Gate http://iesdp.gibberlings3.net/ieformats/itm_v1.htm). Some of variables can't be read directly (like dword) (won't show the data it should).
A java based NearInfinity converts binary dword data in this way:
public static int convertInt(byte buffer[], int offset)
int value = 0;
for (int i = 3; i >= 0; i--)
value = (value << 8) | (buffer[offset + i] & 0xFF);
return value;
Now, how Python code would look like? I've checked binascii module with no luck.I have
plik = open('bow08.itm', 'rb')
try:
tekst = plik.read()
finally:
plik.close()
# char array - works
print tekst[0x0004:0x0004+4]
# resref - works
print tekst[0x003a:0x003a+8]
#dword
print tekst[0x004c:0x004c+4]
and the dword (and few other variables) won't show anything (will output binary something), the java snippet in my first post from NearInfinity converts that binary code into a normal data -
Did you know that verizon charges ¢50 for calls from the US to Canada? Just dialing an area code like 604 (Vancouver, CA), will create charges at a rate of ¢50/minute. Amazing that they can charge this much for a call to Canada. I know they have it somewhere in their contract/website.
Did you know that verizon charges ¢50 for calls from the US to Canada? Just dialing an area code like 604 (Vancouver, CA), will create charges at a rate of ¢50/minute. Amazing that they can charge this much for a call to Canada. I know they have it somewhere in their contract/website.
-
My Nokia N95 doesn't show the codes like *#0000# a...
My Nokia N95 doesn't show the codes like *#0000# and *#06# anymore. Actually all the codes , even those for restoring to the factory settings don't work anymore. Now when i type them in , the phone only bips once and that's all. They worked before , but i don't know exactly what may have caused this error. Maybe some application i installed on it or what else!? Please help. Thank you.
>
Thanks to john3136 . That�s what i neededHELLOOOOO! Where's john3136's Dukes then???? -
Why are most websites only displaying code like text?
Almost all of the web sites that I frequent have began displaying code like text on a blank white background. Some sites still have hyperlinks and images here and there with random text, but others are fully blank with what appears to be the code of the website showing. I wasn't able to access this web site until I tried multiple times and it magically worked, but others are still not working. The only sites that I have tested that have worked from the start are Google related sites (Gmail, Google, Youtube). My yahoo email is inaccessible, which is an important email for me and all other sites that i frequent are inaccessible. One major thing to note is that the sites are also inaccessible on Internet Explorer. This would typically lead you to believe that the problem lies with your connection in some way. I have reset my router/modem and it had no effect. I also have ran CCleaner and have deleted temp files, cookies, and caches. I have tried running Mozilla in safe mode with add-ons disabled as well. My malware protection and antivirus protection find no issues after completing full scans. One last thing to note is that, on both Firefox and IE, certain sites allow to me to access the homepage, such as yahoo, but once I attempt to check my mail the random display of code appears. On IE it simply says that the site cannot be displayed once I click to check my mail. Gmail works perfect on the other hand. The only things that I have done during this time are:
Setup a LogMeIn account (Hamachi) and connected my PC to their service
Downloaded and began using Malewarebytes software to remove malware that I had picked up
Other than those two things it has been the same usual actions on my PC. Could the malware that I had still be effecting me somehow even though it was found/deleted? Is my router to blame even though resetting it does not help? After all the things I have tried, what could it be?What is the content type of those pages if you check that via Tools > Page Info > General?
Is that text/html as it should be or text/plain as your screenshot would suggest?
You can also check the Net log via the Web Console (Web Developer > Web Console;Ctrl+Shift+K)
*https://developer.mozilla.org/en/Tools/Web_Console
*https://developer.mozilla.org/en/Using_the_Web_Console
This can be a problem with your firewall that modifies the server response headers if the settings in Firefox are correct.
*http://kb.mozillazine.org/Standard_diagnostic_-_Firefox
*https://support.mozilla.org/kb/Basic+Troubleshooting
A possible cause is security software (firewall,anti-virus) that blocks or restricts Firefox or the plugin-container process without informing you, possibly after detecting changes (update) to the Firefox program.
Remove all rules for Firefox and the plugin-container from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process and the updater process.
See:
*https://support.mozilla.org/kb/Server+not+found
*https://support.mozilla.org/kb/Firewalls
Try to boot the computer in Windows Safe mode with network support (press F8 on the boot screen) as a test to see if that works. -
Can I import binary in Flash CS5 and export swf, without AS code likes "Embed" ?
Can I import binary in Flash CS5 and export swf, without AS code likes "Embed" ?
I know I can use AS code,likes "[Embed]" metadata to embed binary in swf. But , how can I do that in Flash CS5 ?Have a look at this: http://stackoverflow.com/questions/7816231/how-to-use-as3-to-load-binary-data-from-web-ser ver
-
When I add some code like the below to a webpage
sometimes when I add some code like the below to a
webpage[dwmr mx 2004 or cs4], the page destroyed/currupted like the
css missing[is inside a template], well I think page stills
displays ok online but in "design view" default fonts appear etc
destructions, well how I recover page just prior entered the code ?
<input name="st" type="hidden" value="<?=
isset($_GET['sort'])?$_GET['sort']:(isset($_GET['price'])?'price':(isset($_GET['popular'] )?'popular':(isset($_GET['wd4'])?'wd4':(isset($_GET['salon'])?'salon':(isset($_GET['manual '])?2:1)))));
?>" />
<script type="text/javascript">
function highlightTableCells()
document.getElementById('cars').style.backgroundColor='#00CC66';
switch(document.getElementById('st').value)
case "price":
document.getElementById('price').style.backgroundColor='#00CC66';
break;
case "2": //manual
document.getElementById('manual').style.backgroundColor='#00CC66';
document.getElementById('manual2').style.backgroundColor='#00CC66';
break;
case "1":
document.getElementById('auto').style.backgroundColor='#00CC66';
document.getElementById('auto2').style.backgroundColor='#00CC66';
break;
case "salon":
document.getElementById('salon').style.backgroundColor='#00CC66';
document.getElementById('salon2').style.backgroundColor='#00CC66';
break;
case "wd4":
document.getElementById('wd4').style.backgroundColor='#00CC66';
document.getElementById('wd42').style.backgroundColor='#00CC66';
break;
case "0":
document.getElementById('all').style.backgroundColor='#00CC66';
break;
case "popular":
document.getElementById('popular').style.backgroundColor='#00CC66';
document.getElementById('popular2').style.backgroundColor='#00CC66';
break;
case "4wd":
document.getElementById('wd4').style.backgroundColor='#00CC66';
document.getElementById('wd42').style.backgroundColor='#00CC66';
break;
case "mpvs":
document.getElementById('mpvs').style.backgroundColor='#00CC66';
break;
case "cabrios":
document.getElementById('open').style.backgroundColor='#00CC66';
break;
case "a":
document.getElementById('a').style.backgroundColor='#00CC66';
break;
case "b1":
document.getElementById('b1').style.backgroundColor='#00CC66';
break;
case "b2":
document.getElementById('b2').style.backgroundColor='#00CC66';
break;
case "c":
document.getElementById('c').style.backgroundColor='#00CC66';
break;
case "d":
document.getElementById('d').style.backgroundColor='#00CC66';
break;
case "d1":
document.getElementById('d1').style.backgroundColor='#00CC66';
break;
case "e1":
document.getElementById('e1').style.backgroundColor='#00CC66';
break;
case "e2":
document.getElementById('e2').style.backgroundColor='#00CC66';
break;
case "f":
document.getElementById('f').style.backgroundColor='#00CC66';
break;
case "g":
document.getElementById('g').style.backgroundColor='#00CC66';
break;
case "h1":
document.getElementById('h1').style.backgroundColor='#00CC66';
break;
case "h2":
document.getElementById('h2').style.backgroundColor='#00CC66';
break;
case "i":
document.getElementById('i').style.backgroundColor='#00CC66';
break;
case "j":
document.getElementById('j').style.backgroundColor='#00CC66';
break;
case "k1":
document.getElementById('k1').style.backgroundColor='#00CC66';
break;
case "k2":
document.getElementById('k2').style.backgroundColor='#00CC66';
break;
case "n":
document.getElementById('n').style.backgroundColor='#00CC66';
break;
case "p1":
document.getElementById('p1').style.backgroundColor='#00CC66';
break;
case "p2":
document.getElementById('p2').style.backgroundColor='#00CC66';
break;
case "s":
document.getElementById('s').style.backgroundColor='#00CC66';
break;
case "u":
document.getElementById('u').style.backgroundColor='#00CC66';
break;
</script>Take a look at a previous thread on this topic: http://forums.adobe.com/message/5099353
-
Python code blocks in LV 8.2
Is there anyway to put Python code nice and easily into LV8.2
Or will i have to build it or convert it into another codetype?
Ta for help.http://labpython.sourceforge.net/
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice -
I write the code like this ...i didn't get output properly
Hi Experts,
I write the code like this ...i didn't get output properly......the selected file name is not copied to v_fname........
Points will be rewared...
tables : kna1.
parameters : P_FNAME type rlgrap-filename.
data : v_fname(200) type c . "lower case.
data : begin of itab occurs 0,
kunnr type kna1-kunnr ,
end of itab .
select kunnr from kna1 into table itab up to 50 rows .
at selection-screen on value-request for P_FNAME .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = v_fname
STATIC = ' '
MASK = ' '
CHANGING
FILE_NAME = P_FNAME
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
start-of-selection.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = 'v_fname'
FILENAME =
FILETYPE = 'ASC'
TABLES
DATA_TAB = ITAB
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.You are exporting field v_fname, not importing it. The field v_fname isn't for the file name anyway; field p_fname is for the file name. You also need to pass your file name to the function module GUI_DOWNLOAD for it to work.
- April King -
Hi experts
i need tax percentage , i used this function module
MM_ARRANG_GET_TAX_PERCENTAGE
import parameter
I_MWSKZ = c1.
I_BUKRS = 1000
I_WAERS = inr
iam geting this message for some tax code like c1 ,t2, t3
message : Tax code C1 country IN does not exist in procedure ZAXINN
other taxcodes v0,v2 s2,s3 are got percentage, it's proper result.
please give me sugession.HI Friend,
Use the Functional module FI_TAX_GET_CONDITION, this will be used in case ur using the in acsess sequence tax classification (ie A003 table)
pass the inputs like
I_BUKRS >> company code
I_LAND1>> country
I_KALSM>> tax procedure
I_MWSKZ>> tax code
I_TXJCD>> tax juriduction code
I_KSCHL>> condition type
I_KTOSL>> transaction
I_TDATE>> date
the functional module your using will not give the proper results
Regards
Pramod -
Is there a way that I can add tracking code (like google analytics) to a DPS Single Edition app? If not, does the apple app store offer any analytics for a DPS Single Edition app after it is published there?
Take a look at a previous thread on this topic: http://forums.adobe.com/message/5099353
-
How to execute these T-Codes like BLOC , BUNL
Dear All,
How to execute these T-Codes like BLOC , BUNL.
Follow this path to view these T-Codes.
( 1.) Execute CO02 or CO03.
( 2.) Put the Order Number & select Display Overview & Press Enter.
( 3.) At Status , you will see an Information Button in Blue colour. (Blue Coloured Button with i written on it)
( 4.) Press this i button.
( 5.) Below you will see the filter button , here it is written ACTIVE STATUS.
Click once on it. It will display ALL STATUSES.
( 6.) Here we see a List of Status. Click once on any one & then click on F1 button.
( 7.) A new screen will open. Click on the "Where Used List".
( 8.) It will now show the list of T-Codes.
What these T-Codes depict ?
How to execute these T-Codes ?
Thanks & Regards,
Vivek SharmaHi,
These are the Business Transactions which can be possible withe the Status on which you have pressed F1.
BLOC - Lock
BUNL - Un-lock
Etc..
Check for these Business Transactions in the T.Code: BS22
Best Regards,
Siva -
Recently my iMac's hard drive was copied as part of a computer forensic examination. The forensic expert filed a report with the court saying that he found emails on my computer that prove I have forged email headers, as well as used or tested remailing or anonymizing software. The emails he included with the report are listed as having been sent by [email protected] with the name "Barry Warsaw" on them.
My first guess was that these emails were spam which was sent to me and immediately deleted. Further searching led me to the folks who operate the Python.org thing, whatever in the heck that is. They informed me that what was found was a very old piece of Python "sample data" which some computer makers and software writers include at the time of manufacture. They said there was "nothing sinister" about it and the "expert" doesn't know what he's doing.
Does anyone here have any idea what's going on? I'm sensing that their forensic "expert" has either misidentified a piece of innocent email or code or is running a scam on somebody. I've put a copy of one of the emails below. Thanks.
Return‐Path: <[email protected]> Delivered‐To: [email protected] Received: by mail.python.org (Postfix, from userid 889)
id C2BF0D37C6; Tue, 11 Sep 2001 00:05:05 ‐0400 (EDT) MIME‐Version: 1.0
Content‐Type: multipart/mixed; boundary="h90VIIIKmx" Content‐Transfer‐Encoding: 7bit Message‐ID: <[email protected]> From: [email protected] (Barry A. Warsaw)
To: [email protected] Subject: a simple multipart Date: Tue, 11 Sep 2001 00:05:05 ‐0400 X‐Mailer: VM 6.95 under 21.4 (patch 4) "Artificial Intelligence" XEmacs Lucid X‐Attribution: BAW X‐Oblique‐Strategy: Make a door into a window
‐‐h90VIIIKmx Content‐Type: text/plain Content‐Disposition: inline; name="msg.txt" Content‐Transfer‐Encoding: 7bit
a simple kind of mirror to reflect upon our own
‐‐h90VIIIKmx Content‐Type: text/plain Content‐Disposition: inline; name="msg.txt" Content‐Transfer‐Encoding: 7bit
a simple kind of mirror to reflect upon our own
‐‐h90VIIIKmx‐‐
Like (0)
ReplyBarry Warsaw from Python.org contacted me with this information. I'll post it here in the event that anyone else might eventually run into the same thing. By the way, the computer forensic "expert" who stated that these emails were evidence of some sort of nefarious activity turns out to be far less than an expert after all. So much for his "credentials." It's official - he doesn't know what he's doing.
From: Barry Warsaw <[email protected]>
Subject: Re: Question
Date: May 4, 2011 4:37:02 PM EDT
To: [email protected]
Cc: [email protected], Tom Kirkman <[email protected]>
Tom contacted me separately via my [email protected] email address, and I've already replied to him as best I can determine. He sent a snippet of a few email headers from the messages in question, and I searched for a Message-Id I found in the snippet. As best I can tell, the message was some sample data included in a commit message to python-checkins back in 2001. I haven't even looked to see if the file is still in the tree, but just to tell you how old that was, it's not clear whether we're talking about the email package, mimelib or something older (I just don't remember ;). And this was back when we were using CVS!
It is sample data used to drive a unit test and was probably written around 2001. This tests a library that parses email addresses. The sample data is just made-up stuff to test the library, so it has to look like an email message. Sample data for unit tests don't change over time. As a matter of fact, this particular message still lives in the Python source tree:
http://hg.python.org/cpython/file/b4b0a1458638/Lib/email/test/data/msg_04.txt
I hope my explanation to Tom included enough relevant background information on Python, our libraries, unit tests, sample data, commit process, etc. so that he can clearly tell there was absolutely nothing sinister about the file. In fact, it was never actually *sent* anywhere - it was just part of a message included in a commit notification.
Another thing I thought about: I think it's possible his computer manufacturer included a copy of the Python source code on his machine, or maybe he downloaded and installed Python at some time in the past, or possibly installed some software that *included* Python and its source tree. Either way, I can't possibly imagine how this could be interpreted as anything other than totally innocent. It's not even spam.
Cheers,
-Barry Warsaw -
Delete unwanted company code, like sample company codes
Hi Expert,
I would like to have advice on deleting unwanted company codes, for example, country sample company codes.
I would like to have remaining company code of 0001, and my client company code, say 1000, only.
Is it enough to delete these unwanted company code using EC01?
I will make sure:
No transactional data for these company codes, say Table BSEG
No master data for these company codes, GL: SKB1, Vendor: LFB1, Customer: KNB1, etc
Thanks and regards,
sbmelHi,
You can delete un-wanted Company codes from the system. But you will get frustation with this task. I am telling this based on my experience for 2 times..
You have to archive data and company codes before started deleting this. and you have to delete Profit centers, Cost centers, Cost elements, GL Accounts, Activity types and all other master data.. First we have to delete the dependant data (I mean assigned child data). other wise it will give many errors..
For example: If you delete standard hierarchy with out deleting Cost centers or profit centers firsst,,,then you can not delete profit centers or cost centers..
So we have to delete one by one logically.. hope it helps..
thanks
Fit 4 Nothing -
How to write python code in Data Services ?
I read that you can use python programming to do tasks that custom SAP Data Services Designer components cannot do. Here is the link for that -
SAP Data Services/BODS equivalent of Microsoft SSIS Script Task
I don't know where I can type my code in DS / BODS. I see a script in the designer window, but it has nothing to do with python. Can someone show me
where it is and how to do programming in SAP DS ?
In SSIS, creating a script with programming language is very easy. Just drag and drop the Script component and start coding right away.
Unfortunately, SAP does not seem to be so simple.Hi Terry,
There is simple solution provided by Ramesh Murugan then why do you want go for hard way !! Not sure your intention
For your questions
Can we do the ENTIRE etl in python ?
Not sure but I didn't get any complicated scenarios so for and also we need to consider performance as well
Challenge with some complicated scenarios with BODS !! We happy to provide solutions
But every tool has unique capability !!
Regards,
Manoj
Maybe you are looking for
-
Hi. After loading a picture into Photoshop some of the menu tools are greyed out and I cannot use the keyboard short cuts, for instance I cannot use Ctrl + T for free transform, how do I resolve this problem. In addition the tool Icons are so small I
-
How can I set up Gmail on my iPhone with a different domain name?
I'm an ASU student so my email ends in @asu.edu. However its a Gmail account and I just got a new iPhone and I would really like to set it up through the mail app but it won't let me. Every time I type my email and password in the phone says: "The us
-
Hello I'm having a problem with italics font in .svg files. Illustrator shows the font correctly (times new roman) but if I open it in a browser (firefox) there are no italics. Where did I go wrong? I made some svg files last year, and didn't have th
-
Contouring from point geometry
Hi all, Is any spatial utility or methods are available for creating contour or isopleths on Oracle spatial? I want to create contour from point geometry show it on map (using mapviewer) similar to this site. http://www.bom.gov.au/cgi-bin/silo/rain_m
-
Accessing photos outside of iphoto
I would like to be able to access photos in the iphoto library without having to export them or create a separate file. Though I like how iphoto organizes and displays photos I tend to use my photos outside it- using the as part of artwork in photosh