Front fork oil

Front fork oil

Can I use motorcycle fork oil in my RockShox Revelation forks?

Technical spec states that it should be 5wt, will this stuff from eBay be correct?

u/RomfordNavy — 5 days ago
▲ 0 r/Python

Other Python forums - Stack Overflow

Not sure if I am allowed to discuss other forums on here but I'm sure someone will tell me if not.

It is just me of has anybody else encountered problems with the 'moderators' on Stack Overflow Python forums recently? To say I've found them to be a self-righteous bunch of destructive power-crazy control-freaks would be a bit of an understatement. Anyone else had problems on there?

reddit.com
u/RomfordNavy — 6 days ago

Turn off print() output

Is there some way to switch off print() output when Python is not running in interactive mode?

When I am testing it is good to see these messages on screen but when the process is running without an interactive terminal to output to it feels like it would be good to find a way to stop that output. However I don't know whether the overhead of these messages going nowhere matters or not.

reddit.com
u/RomfordNavy — 2 months ago

Thoughts on HTML / Python template delimiters

Working on creating a small templating type engine to allow mixing of HTML and Python code and considering what to use as the delimiters between each. Beginning suggestion is:

HTML: <- begin HTML block

&lt;% Python expression %&gt;

Python: <- begin Python code block

&lt;# HTML text #&gt;     &lt;- output HTML with newline
&lt;#= HTML text #&gt;    &lt;- output HTML inline (no newline)
? "HTML text"       &lt;- output HTML whole line
?? "HTML text"      &lt;- output HTML whole line (on same line)

Are there more suitable 'Pythonic' delimiters which I should be using?

reddit.com
u/RomfordNavy — 3 months ago

Local variables changed during exec() in Python 3.14 are not persistant

There seems to be a problem with changing a local variable within exec():

test = "test1"
exec("test = 'test2'", {}, {"test": test})
print(test) # &lt;- erroneously returns test1

returns 'test1' - the change to 'test' during exec() has not persisted

However if passed inside a dict variable:

localDict = {"test": "test1"}
exec("test = 'test2'", {}, localDict)
test = localDict["test"]
print(test) # &lt;- correctly returns test2

It seems to work for some reason and returns 'test2'!

Is this a bug in exec() in Python 3.14?

reddit.com
u/RomfordNavy — 3 months ago

Accessing source code from importlib module

I notice that the source code from an importlib module can be read using inspect module. However is there an alternative way of accessing this code so that it can be modified? Presumably inspect.getsource must have some method of finding this.

import inspect
import importlib
spec = importlib.util.spec_from_file_location(module_name, source_path)
module = importlib.util.module_from_spec(spec)
print(inspect.getsource(module))
reddit.com
u/RomfordNavy — 3 months ago

Compile only if .pyc is out-of-date?

Is there some way I can compile a .py script into a .pyc but only if it is missing or out-of-date with the.py file?

I am trying to compile the file if necessary and then run it from within Python, can exec() run a .pyc file?

import py_compile
py_compile.compile('Child.py')
exec(open('Child.py').read())

This works but recompiles the file on every run.

reddit.com
u/RomfordNavy — 3 months ago

How to call a *.py from within Python along with a variable?

What is the correct way to call a *.py program script from within Python while making a variable from the parent available.

Parent.py

class cParent:
    test = "test"
oParent = cParent()
import Child

Child.py

print(oParent.test)     # this line fails presumably because oParent is out of scope
reddit.com
u/RomfordNavy — 3 months ago

Create .pyc files for simple scripts

It it possible to configure Python to create a .pyc bytecode file for all simple *.py files which are run? It seems that by default it only creates a .pyc for any classes which is imported not for a program file itself.

reddit.com
u/RomfordNavy — 3 months ago

Well, had a good listening session today and here are my thoughts:

  • Fiio FT7 - quite clinical, vocals sounded 'dry'
  • Meze 105 - much warmer midrange but maybe lacked the spacial seperation and overall range of the Fiio, also very tight clamping force
  • Audeze MM-100 - similar to the Meze, lacking the detail and overall range of the Fiio
  • Hifiman Arya Organic - beautiful vocals but big hole in the treble (2khz?)
  • Hifiman HE1000 Stealth - Hifiman have fixed the hole in the treble here but the result is just way too bright, they make even the FT7 sound warm and not so analytical
  • Dan Clark Noire XO - seemed to lack punch and dynamism, not as impressed as I thought I would be with them
reddit.com
u/RomfordNavy — 3 months ago

Somewhere recently I saw an example of what was probably a WSGI server which had code to run the *.py file which had been requested, however can't seem to find that again. Lots of examples of simple WSGI servers but not the example I was looking for, anyone know where I might find that example?

reddit.com
u/RomfordNavy — 4 months ago

Coming from the Foxpro world we used Textmerge to output multiline text such as HTML, is there a similar method available in Python?

In Fox an example might be:

Use Customer
Set Textmerge On
\&lt;html&gt;
\&lt;head&gt;
\&lt;title&gt;HTML from FoxPro&lt;/title&gt;
\&lt;/head&gt;
\&lt;body&gt;
\&lt;h1&gt;Customer List&lt;/h1&gt;
\&lt;hr /&gt;
Scan
   \Company name is &lt;&lt;Upper(Company)&gt;&gt;
   \&lt;br /&gt;
Endscan
\&lt;/body&gt;
\&lt;/html&gt;
Set Textmerge Off
Use In Customer

reddit.com
u/RomfordNavy — 4 months ago

Can anyone tell me how to use Python to return a simple HTML page using something akin to the ASP Request/Response objects please?

There are lots of examples using various frameworks but can't find anything showing how to just do something very basic.

reddit.com
u/RomfordNavy — 4 months ago