Hey #Python folks (and I'm looking especially at you @treyhunner) what's the most #pythonic way to “write to file if it exists, else create it and then write to it”?
`open(filename, ‘x’)` only works once, AIUI. I want a code snippet (or library!) that will work every time
While working with #Python, I miss being able to use an assignment statement as an expression, particularly when constructing a while loop.
Example:
while ((myDate = NextFOM (myDate)) <= EndDate):
print ("First of Month", myDate)
From what I've read, it looks like a #Pythonic way to rewrite the above code looks like this:
while True:
myDate = NextFOM (myDate)
if myDate > EndDate:
break
print ("First of Month", myDate)
While working with #Python, I miss being able to use an assignment statement as an expression, particularly when constructing a while loop.
Example:
while ((myDate = NextFOM (myDate)) <= EndDate):
print ("First of Month", myDate)
From what I've read, it looks like a #Pythonic way to rewrite the above code looks like this:
while True:
myDate = NextFOM (myDate)
if myDate > EndDate:
break
print ("First of Month", myDate)
This will get even better in 1 or 2 weeks
github.com/cirospaciari/socketify.py
#python #webdevelopment #pythonic
Today we have a lot of new people helping the socketify GitHub project, thank you for all your support!
Is inspiring to see this that means a lot
#python #webdevelopment #pythonic
My book "Pythonic Programming" is featured and on special sale today (12/20/2022) from 6PM to 11PM EST at https://pragprog.com/titles/dzpythonic #12DaysOfPragProg #python #pythonic #programming #dzpythonic
#dzpythonic #programming #pythonic #python #12daysofpragprog
OK, fellow #Python devs. I’ve donned my asbestos suit and am ready to open the door to the inferno. 😆 I’m writing a piece for my students (elementary Python class) on writing “Pythonic" code, which might expand into a blog entry at some point. So, with that in mind...
What are some common things that tell you a piece of code is Pythonic?
Could be stylistic, could be functional, anything's good. I'm just looking for tell-tale signs of #Pythonic code vs. code written with an “accent" from another language. (A couple I’ve already scribbled down: list comprehensions, lambda over map/filter…)
⚠️ New #PYTHON #MALWARE package detected by
phylum.io
just published to #pypi. Drops malware to developer machines.
VirusTotal
https://virustotal.com/gui/file/33df1d9c50a9bd9d3e71dc61c0a7f41f7ca51612e9c3babcea927adde169e62d
PyPI Page
https://pypi.org/project/shaders/
#python #malware #pypi #opensource #infosec #pythonprogramming #pythonic
Just read this article on being #Pythonic for one of my classes
https://towardsdatascience.com/how-to-be-pythonic-and-why-you-should-care-188d63a5037e It's on medium, so... sorry for the ads and javascript.
Credibility seems to be very important to the author. Unashamedly so, as he is a little smug at certain points.
"If you care about your credibility in the software world and want to proudly call yourself a Python developer, make sure you know and use some of these techniques..."
Dude, I'm just happy when my code actually works.
« Use your #RaspberryPi as a #DataLogger : Here's how to log the CPU temperature of a Raspberry Pi and create a spreadsheet-based report on demand » using #Pythonic and thus #Python > https://opensource.com/article/22/3/raspberry-pi-data-logger
#raspberrypi #datalogger #pythonic #python
The video of the talk "Maps with GeoDjango, PostGIS and Leaflet" 🗺️ I presented at #DjangoConEurope 2019 🇪🇺 in Copenhagen 🇩🇰 has almost reached 15000 views. 🚀
I'm very happy and also surprised at the same time.
See you at the next #pythonic conference. 🐍
https://www.youtube.com/watch?v=aEivCtavw-I