Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Anyone know Python?
Page 3 of 3 | |||||
Author | Message | ||||
RetroJoe Senior Member Joined: 06/08/2020 Location: CanadaPosts: 290 |
Python is famous (infamous?) for its anal attention to matters of code style and formatting - according to "The Zen of Python", there is usually "one best way" to do anything, including formatting code for maximum clarity and readability. I haven't used this personally yet, but a colleague just turned me on to Black, which is emerging as a popular Python code prettifier and formatter. My hunch is it could also untangle logic errors arising from whitespace issues. I guess the name is a riff on Henry Ford's "any color you want, as long as it's black" Model T, or maybe Spinal Tap's "none more black" album. P.S. I just picked up a handful of Raspberry Picos (at $5 a pop, why not?), and having lots of fun at the moment with MicroPython making LEDs blink and buzzers buzz! Frankly, I am in awe at the flawless launch of this product, and the huge amounts of quality documentation and developer boards / tools / support for the RP2040 in such a short time. Definitely something to keep your eye on if you are an MCU and/or Python enthusiast. Edited 2021-05-01 15:36 by RetroJoe Enjoy Every Sandwich / Joe P. |
||||
CircuitGizmos Guru Joined: 08/09/2011 Location: United StatesPosts: 1421 |
US$ 9 is the lowest cost I've found (including shipping). Micromites and Maximites! - Beginning Maximite |
||||
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1676 |
Does anyone know how to limit the number of items added to a csv file in Python? I'm trying to make a graph and to do it I made a csv file that adds values to it every minute I need the csv file to only add 30 times then loop so it always saves the last 30 reads like windspeed every minute it writes it to the csv file but I want it to always only have the last 30 minutes worth of windspeed in there. This is my csv datafile, at the moment it keeps adding till it gets to CSVFILENAME = 'data.csv' CSV_FILE_MAX_BYTES = 2048*2048 #Max. size of logfile before rotating. CSVFILENAME = 'data.csv' #every minute write these values csvfile=open('data.csv','a', newline='\n') #Write Data for graph to CSV obj=csv.writer(csvfile) now=datetime.now() readings=[(now.strftime("%a")) , (now.strftime("%H:%M")) ,(Data.temphigh) , (Data.templow) , (Data.sea_level_pressure) , (Data.relative_humidity), (round(Data.wind,2)) , (round(Data.gust,2))] obj=csv.writer(csvfile) obj.writerow(readings) csvfile.close() |
||||
RetroJoe Senior Member Joined: 06/08/2020 Location: CanadaPosts: 290 |
I ordered mine from Canakit Unit price was CAD 5.25, but indeed, with shipping and taxes it is around ten bucks each. Still not going to break the bank, but there is definitely something funky with a business model where the shipping cost is approximately the same as the price of the merchandise! Enjoy Every Sandwich / Joe P. |
||||
RetroJoe Senior Member Joined: 06/08/2020 Location: CanadaPosts: 290 |
@Lew247, there are Python classes explicitly for log handling Otherwise, I'm guessing you will need to do the "handling" yourself by counting the number of written records and comparing it to your threshold. Enjoy Every Sandwich / Joe P. |
||||
hitsware2 Guru Joined: 03/08/2019 Location: United StatesPosts: 705 |
>> the shipping cost is approximately the >> same as the price of the merchandise! Signs of the times All these mass produced boards are becoming cheaper ... my site |
||||
Tinine Guru Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
@RetroJoe Spinal Tap: "I do not, for one, think that the problem was that the band was down. I think that the problem may have been, that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf. Alright? That tended to understate the hugeness of the object." -- David St. Hubbins |
||||
RetroJoe Senior Member Joined: 06/08/2020 Location: CanadaPosts: 290 |
>> same as the price of the merchandise! Signs of the times All these mass produced boards are becoming cheaper ... I suppose, but there is also some good old-fashioned profiteering going on. These devices are tiny and feather-light, and much heavier items ship direct from China for much cheaper. In other words, Canakit is most definitely making a healthy margin on shipping these domestically. That's their prerogative, but my point (and Gizmo's) is there is apparently no place on Earth you can buy a Pico for the highly-touted $4 price point. Enjoy Every Sandwich / Joe P. |
||||
RetroJoe Senior Member Joined: 06/08/2020 Location: CanadaPosts: 290 |
Spinal Tap: "I do not, for one, think that the problem was that the band was down. I think that the problem may have been, that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf. Alright? That tended to understate the hugeness of the object." -- David St. Hubbins Great dialogue, almost all of it ad-libbed ("What's wrong with being sexy?"). Without a doubt the best mockumentary ever, even if you include Christoper Guest's later works. What's awesome is you're never sure who or what the target of the mocking is - I think if I had to pick, it is "pretentiousness" in all its forms - almost every character is a pompous ass. Re the Stonehenge production number and song, I'm almost certain it's Jethro Tull they are ridiculing, arguably the most pretentious British "art rock" group in history... starting with the name of the band. Still, Martin Barre's guitar solo in "Aqualung" has stood the test of time - easily in my Top Ten list. For the electro-geeks on this forum, may all your projects "go to 11" :) Enjoy Every Sandwich / Joe P. |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5883 |
In other words, Canakit is most definitely making a healthy margin on shipping these domestically. That's their prerogative, but my point (and Gizmo's) is there is apparently no place on Earth you can buy a Pico for the highly-touted $4 price point. In January I paid $5.75AU which at the time was just about spot on $4US Freight was also not too bad for AU. Jim VK7JH MMedit MMBasic Help |
||||
CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 1985 |
https://www.theregister.com/2021/05/05/aws_chalice_python/ |
||||
zeitfest Guru Joined: 31/07/2019 Location: AustraliaPosts: 375 |
I bought two for about AU$5 each, sad hype-worshipping loser me !! Anyway they are free with this magazine : hackspace |
||||
Page 3 of 3 |
Print this page |