09 April 2018

python string concatenation is a bad practice

i think because python is a scripting language, people tend to thing it's super fine to do something like this:

>>> val + '-string'

the problem is that the + operator does not do any casting of the variable to make it compatible with the string. this sort of thing will throw an error if the type of val is anything other than a string.

check it:

>>> val = None
>>> val + '-string'
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    val + '-string'
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
>>> '{}-string'.format(val)
'None-string'

>>> val = 4
>>> val + '-string'
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    val + '-string'
TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>> '{}-string'.format(val)
'4-string'

now, you could force cast it using str(val), but that seems silly when you can just use the format() method on the string object to handle things for you.

02 March 2018

python is referential

this is often misunderstood about python, especially if you are accustomed to other languages, such as C/C++.

>>> class thing(object):
...     def __init__(self, some):
...         self.some = some
...     def add_on(self, addition):
...         self.some = self.some + addition
... 
>>> a = thing("hello")
>>> print(a.some)
hello

>>> b = a
>>> print(b)
<__main__.thing object at 0x7f9d267cf7f0>
>>> print(a)
<__main__.thing object at 0x7f9d267cf7f0>
>>> print(b.some)
hello

>>> a.add_on(", world")
>>> print(a.some)
hello, world
>>> print(b.some)
hello, world

>>> print(a)
<__main__.thing object at 0x7f9d267cf7f0>
>>> print(b)
<__main__.thing object at 0x7f9d267cf7f0>

28 November 2017

fedora magazine

last week, this interview with fedora magazine (online) was published. thanks to charles profitt for the write up.

https://fedoramagazine.org/mark-mcintyre-fedora/


26 November 2017

read 'em and weep

well, i am finally getting to the point of needing reading glasses.

i recently had my contact prescription adjusted to re-calibrate one eye handling objects less than arm's length and the other focusing at a distance. the focal lengths left a big transition between the two. the adjustment shortened that gap.

the result is a decent, unaided distance focus, but the cost seems to be my reading the closer things. of course, my age plays a factor in this too. i am not dismissing that. i think even if i stopped wearing the lenses at night, i wouldn't regain enough of my near-sightedness to avoid the readers.

as such, i have purchased reading glasses which are compact enough for the case to fit in my pocket. unlike some colleagues, i have no problem accepting this sort of thing in my life. if i need them, i need them.

here's the amazon like to what i picked up:

Reading Glasses 2 Pair Black and Gunmetal Readers Compact Folding Glasses for Reading for Men and Women Case Included +1.25 https://www.amazon.com/dp/B01DKW5P9U?ref=yo_pop_ma_swf
nice and compact!

i knew it was coming. gotta learn to adjust.

23 September 2017

grammar and geeks

ok, let's get a few things straight.

( ) - these are parentheses. no one questions the name of these characters. no one calls them "rounded brackets," for obvious reasons.

[ ] - these are brackets. not square brackets, which is redundant. they are not square braces, if anyone actually calls them that. they are brackets!

{ } - these are braces. not curly brackets. definitely not curly braces (more redundancy).

why is this so confusing for my fellow geeks who pride themselves on being so precise about every other detail in their lives? it's time to learn the proper names of the punctuation which is so commonly used in our lives everyday in order that they don't appear as idiots.

it's not hard. we are not idiots. these are the names. let's use them.

21 February 2017

published older posts

i had imported my older posts from my wordpress blog into this blog in the middle of last year. but when i had imported them, the publish dates all ended up being the day of import rather than the original date. so, i spend a few hours this past sunday getting the dates fixed by hand.

i resized all the pictures to fit the format of the current theme. i still need to fix a few links in several posts to have them reference other posts within this blog now. i'll tackle that later.

i'm also considering hosting my own site again using mezzanine (python). that might take some time to set up as i learn the environment. until then, i'm here!

14 February 2017

return of the 5GHz

i finally was up and running on saturday with a new and different router to provide mock manor with 5GHz frequencies. streaming video is noticeably slower over 2.4GHz. i opted for a netgear nighthawk x4s. someone i work with has talked this router line up.

the setup was easy and all is good. i actually like the design on the router, specifically the lights on the front kinda top of the router. my others had a flatter face on the front which hid them a little.

now, i still have a little follow up with linksys about getting the wrt-1900acs working. they had contacted me about working through some steps to get it working. there is probably a chance to get it back to a happy firmware version. i just need to plug it in and troubleshoot it. if i can get it working, it will be my backup router.

in my many years of working with routers, i've not had this much trouble with these devices. and my queries with others surfaced two independent responses for pfsense and unifi devices. i even looked at some more high end hardware feeling that now might be the time for something like that. however, i don't have the closet in which i can install a rack to mount a switch or other metal.

i hope this concludes this adventure.